EscolaLMS/API

View on GitHub
app/Library/ScormHelper.php

Summary

Maintainability
F
3 days
Test Coverage

File ScormHelper.php has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php


namespace App\Library;

Severity: Major
Found in app/Library/ScormHelper.php - About 1 day to fix

    Method updateScoTracking has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function updateScoTracking($scoUuid, $userId, $data)
        {
            $tracking = $this->createScoTracking($scoUuid, $userId);
            $tracking->setLatestDate(Carbon::now());
            $sco    =   $tracking->getSco();
    Severity: Major
    Found in app/Library/ScormHelper.php - About 5 hrs to fix

      Function updateScoTracking has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          public function updateScoTracking($scoUuid, $userId, $data)
          {
              $tracking = $this->createScoTracking($scoUuid, $userId);
              $tracking->setLatestDate(Carbon::now());
              $sco    =   $tracking->getSco();
      Severity: Minor
      Found in app/Library/ScormHelper.php - About 4 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 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

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

            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

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

                public function checkUserIsCompletedScorm($scormId, $userId)
                {
                    $completedSco    =   [];
                    $scos   =   ScormScoModel::where('scorm_id', $scormId)->get();
            
            
            Severity: Minor
            Found in app/Library/ScormHelper.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 convertTimeInHundredth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function convertTimeInHundredth($time)
                {
                    if ($time != null) {
                        $timeInArray = explode(':', $time);
                        $timeInArraySec = explode('.', $timeInArray[2]);
            Severity: Minor
            Found in app/Library/ScormHelper.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

            There are no issues that match your filters.

            Category
            Status