EscolaLMS/API

View on GitHub

Showing 46 of 46 total issues

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

    'h5p' => [
        'fullscreen'            => 'Tela cheia',
        'disableFullscreen'     => 'Desabilitar tela cheia',
        'download'              => 'Download',
        'copyrights'            => 'Direitos de uso',
Severity: Major
Found in resources/lang/pt/laravel-h5p.php and 1 other location - About 3 hrs to fix
resources/lang/ar/laravel-h5p.php on lines 74..103

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 146.

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 2 locations. Consider refactoring.
Open

    'h5p' => [
        'fullscreen'            => 'تكبير الشاشة',
        'disableFullscreen'     => 'تكبير الشاشة غير متاح',
        'download'              => 'تحميل',
        'copyrights'            => 'حقوق الاستخدام',
Severity: Major
Found in resources/lang/ar/laravel-h5p.php and 1 other location - About 3 hrs to fix
resources/lang/pt/laravel-h5p.php on lines 83..112

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 146.

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

Method createScoTracking has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createScoTracking($scoUuid, $userId = null)
    {
        $sco    =   ScormScoModel::where('uuid', $scoUuid)->firstOrFail();

        $version = $sco->scorm->version;
Severity: Major
Found in app/Library/ScormHelper.php - About 3 hrs to fix

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

        private function getStationaryEventsQuery(OrderDto $orderDto): Builder
        {
            $stationaryEventClass = $this->prepareClassName(StationaryEvent::class);
    
            $query = DB::table('stationary_events')
    Severity: Major
    Found in app/Repositories/SearchableEventRepository.php and 1 other location - About 2 hrs to fix
    app/Repositories/SearchableEventRepository.php on lines 58..78

    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 137.

    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 2 locations. Consider refactoring.
    Open

        private function getWebinarsQuery(OrderDto $orderDto): Builder
        {
            $webinarClass = $this->prepareClassName(Webinar::class);
    
            $query = DB::table('webinars')
    Severity: Major
    Found in app/Repositories/SearchableEventRepository.php and 1 other location - About 2 hrs to fix
    app/Repositories/SearchableEventRepository.php on lines 36..56

    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 137.

    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

    Method register has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function register()
        {
            $this->productServiceContract = app(ProductServiceContract::class);
    
            Shop::registerProductableClass(Consultation::class);
    Severity: Major
    Found in app/Providers/ShopServiceProvider.php - About 2 hrs to fix

      Function uploadScormArchive has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function uploadScormArchive(UploadedFile $file)
          {
              // Checks if it is a valid scorm archive
              $scormData  =   null;
              $zip = new ZipArchive();
      Severity: Minor
      Found in app/Library/ScormHelper.php - About 2 hrs 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 uploadScormArchive has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function uploadScormArchive(UploadedFile $file)
          {
              // Checks if it is a valid scorm archive
              $scormData  =   null;
              $zip = new ZipArchive();
      Severity: Minor
      Found in app/Library/ScormHelper.php - About 2 hrs to fix

        Method run has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function run()
            {
                $admin = Role::findOrCreate('admin', 'api');
                $tutor = Role::findOrCreate('tutor', 'api');
                $student = Role::findOrCreate('student', 'api');
        Severity: Minor
        Found in database/seeds/UserTableSeeder.php - About 1 hr to fix

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

              public function down()
              {
                  Schema::dropViewIfExists('searchable_events');
          
                  $stationaryEventClass = StationaryEvent::class;
          database/migrations/2022_05_06_122322_update_searchable_event_view.php on lines 16..46

          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 114.

          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 2 locations. Consider refactoring.
          Open

              public function up()
              {
                  Schema::dropViewIfExists('searchable_events');
          
                  $stationaryEventClass = StationaryEvent::class;
          database/migrations/2022_05_06_122322_update_searchable_event_view.php on lines 53..83

          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 114.

          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

          Method run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run()
              {
                  // first populate roles & permissions
                  $this->call(RoleTableSeeder::class);
                  $this->call(AuthPermissionSeeder::class);
          Severity: Minor
          Found in database/seeds/PermissionsSeeder.php - About 1 hr to fix

            Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run(HeadlessH5PServiceContract $hh5pService)
                {
            
                    $this->hh5pService = $hh5pService;
            
            
            Severity: Minor
            Found in database/seeds/CyfrowyDobrostanSeeder.php - About 1 hr 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 parseScormArchive has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function parseScormArchive(UploadedFile $file)
                {
                    $data = [];
                    $contents = '';
                    $zip = new \ZipArchive();
            Severity: Minor
            Found in app/Library/ScormHelper.php - About 1 hr to fix

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

                  public function down()
                  {
                      $stationaryEventClass = StationaryEvent::class;
                      $webinarClass = Webinar::class;
              
              
              database/migrations/2022_03_30_125821_create_searchable_events_view.php on lines 12..40

              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 104.

              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 2 locations. Consider refactoring.
              Open

                  public function up()
                  {
                      $stationaryEventClass = StationaryEvent::class;
                      $webinarClass = Webinar::class;
              
              
              database/migrations/2022_04_20_120123_remove_searchable_events_view.php on lines 17..45

              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 104.

              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

              Method run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function run()
                  {
                      $courses = Course::with('lessons')->get();
                      $contents = H5PContent::with('library')->get();
                      $scormScos = ScormScoModel::all();
              Severity: Minor
              Found in database/seeds/PostCoursesSeeder.php - About 1 hr to fix

                Function HumanFileSize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function HumanFileSize($size, $unit="")
                    {
                        if ((!$unit && $size >= 1<<30) || $unit == "GB") {
                            return number_format($size/(1<<30), 2)." GB";
                        }
                Severity: Minor
                Found in app/Library/EscolaHelpers.php - About 55 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 return_output has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function return_output($type, $status_title, $message, $redirect_url, $status_code = ''): RedirectResponse
                    {
                        //$type = error/flash - error on form validations, flash to show session values
                        //$status_title = success/error/info - change colors in toastr as per the status
                
                
                Severity: Minor
                Found in app/Http/Controllers/Controller.php - About 55 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 parseScormArchive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function parseScormArchive(UploadedFile $file)
                    {
                        $data = [];
                        $contents = '';
                        $zip = new \ZipArchive();
                Severity: Minor
                Found in app/Library/ScormHelper.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

                Severity
                Category
                Status
                Source
                Language