EscolaLMS/Courses

View on GitHub

Showing 66 of 66 total issues

Method allMain has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        array $search = [],
        ?int $skip = null,
        ?int $limit = null,
        array $columns = ['*'],
        string $orderDirection = 'asc',
Severity: Minor
Found in src/Repositories/Contracts/LessonRepositoryContract.php - About 45 mins to fix

    Method allMain has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            array $search = [],
            ?int $skip = null,
            ?int $limit = null,
            array $columns = ['*'],
            string $orderDirection = 'asc',
    Severity: Minor
    Found in src/Repositories/LessonRepository.php - About 45 mins to fix

      Function updateFromRequest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function updateFromRequest(UpdateTopicAPIRequest $request): Topic
          {
              $topic = $request->getTopic()->loadMissing('topicable');
      
              if ($request->has('topicable_type')) {
      Severity: Minor
      Found in src/Repositories/TopicRepository.php - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function getCoursesListWithOrdering has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getCoursesListWithOrdering(OrderDto $orderDto, array $search = []): Builder
          {
              $criteria = $this->prepareCriteria($orderDto);
      
              if (isset($search['title'])) {
      Severity: Minor
      Found in src/Services/CourseService.php - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method updateInTopic has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function updateInTopic(Topic $topic, Authenticatable $user, int $status, ?int $seconds = null, ?bool $newAttempt = false): void
      Severity: Minor
      Found in src/Repositories/CourseProgressRepository.php - About 35 mins to fix

        Method updateInTopic has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function updateInTopic(Topic $topic, Authenticatable $user, int $status, ?int $seconds = null, ?bool $newAttempt = false): void;
        Severity: Minor
        Found in src/Repositories/Contracts/CourseProgressRepositoryContract.php - About 35 mins to fix

          Function buildProgress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function buildProgress(): EloquentCollection
              {
                  $topicWithProgressId = CourseProgress::where('user_id', $this->user->getKey())->whereIn('topic_id', $this->topics->toArray())->pluck('topic_id')->toArray();
                  $topicsWithoutProgress = $this->course
                      ->topics()
          Severity: Minor
          Found in src/ValueObjects/CourseProgressCollection.php - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function getRulesForTopicContentUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getRulesForTopicContentUpdate(FormRequest $request, TopicContentContract $topicContent)
              {
          
                  // we want to do partial update, so we add 'sometimes' to all rules
                  $partialRules = array_map(fn ($field_rules) => is_array($field_rules) ? array_merge(['sometimes'], $field_rules) : 'sometimes' . $field_rules, $topicContent::rules());
          Severity: Minor
          Found in src/Repositories/TopicRepository.php - About 35 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          use Illuminate\Database\Migrations\Migration;
          use Illuminate\Database\Schema\Blueprint;
          use Illuminate\Support\Facades\Schema;
          Severity: Minor
          Found in database/migrations/2022_11_02_133941_add_column_public.php and 2 other locations - About 30 mins to fix
          database/migrations/2021_06_25_093949_add_finished_to_course_user_table.php on lines 1..32
          database/migrations/2021_09_17_000000_add_can_skip_to_topics_table.php on lines 1..32

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          namespace EscolaLms\Courses\Events;
          
          use EscolaLms\Core\Models\User;
          Severity: Minor
          Found in src/Events/LessonFinished.php and 2 other locations - About 30 mins to fix
          src/Events/Course.php on lines 1..32
          src/Events/TopicFinished.php on lines 1..32

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          use Illuminate\Database\Migrations\Migration;
          use Illuminate\Database\Schema\Blueprint;
          use Illuminate\Support\Facades\Schema;
          database/migrations/2021_09_17_000000_add_can_skip_to_topics_table.php on lines 1..32
          database/migrations/2022_11_02_133941_add_column_public.php on lines 1..22

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          namespace EscolaLms\Courses\Events;
          
          use EscolaLms\Courses\Models\Topic;
          Severity: Minor
          Found in src/Events/TopicFinished.php and 2 other locations - About 30 mins to fix
          src/Events/Course.php on lines 1..32
          src/Events/LessonFinished.php on lines 1..32

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          namespace EscolaLms\Courses\Events;
          
          use EscolaLms\Core\Models\User;
          Severity: Minor
          Found in src/Events/Course.php and 2 other locations - About 30 mins to fix
          src/Events/LessonFinished.php on lines 1..32
          src/Events/TopicFinished.php on lines 1..32

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          <?php
          
          use Illuminate\Database\Migrations\Migration;
          use Illuminate\Database\Schema\Blueprint;
          use Illuminate\Support\Facades\Schema;
          database/migrations/2021_06_25_093949_add_finished_to_course_user_table.php on lines 1..32
          database/migrations/2022_11_02_133941_add_column_public.php on lines 1..22

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 91.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Avoid too many return statements within this method.
          Open

                      return true;
          Severity: Major
          Found in src/Http/Requests/SortAPIRequest.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $course->is_published && $course->hasUser($user);
            Severity: Major
            Found in src/Policies/CoursesPolicy.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $this->sendResponseForResource(TopicAdminResource::make($topic), __('Topic updated successfully'));
              Severity: Major
              Found in src/Http/Controllers/TopicAPIController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false;
                Severity: Major
                Found in src/Http/Requests/SortAPIRequest.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $course->hasAuthor($user);
                  Severity: Major
                  Found in src/Policies/CoursesPolicy.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return $this->sendSuccess(__('Topic deleted successfully'));
                    Severity: Major
                    Found in src/Http/Controllers/TopicAPIController.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language