GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Tracker.php

Summary

Maintainability
D
3 days
Test Coverage
F
42%

File Tracker.php has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *
 * @package    Gems
Severity: Major
Found in classes/Gems/Tracker.php - About 1 day to fix

    Gems_Tracker has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
    {
        const DB_DATE_FORMAT = 'yyyy-MM-dd';
        const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
    
    
    Severity: Minor
    Found in classes/Gems/Tracker.php - About 5 hrs to fix

      The class Gems_Tracker has an overall complexity of 119 which is very high. The configured complexity threshold is 50.
      Open

      class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
      {
          const DB_DATE_FORMAT = 'yyyy-MM-dd';
          const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
      
      
      Severity: Minor
      Found in classes/Gems/Tracker.php by phpmd

      The class Gems_Tracker has 15 public methods. Consider refactoring Gems_Tracker to keep number of public methods under 10.
      Open

      class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
      {
          const DB_DATE_FORMAT = 'yyyy-MM-dd';
          const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
      
      
      Severity: Minor
      Found in classes/Gems/Tracker.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      Function filterChangesOnly has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function filterChangesOnly(array $oldValues, array &$newValues)
          {
              if ($newValues && $oldValues) {
                  // \MUtil_Echo::track($newValues);
                  // Remove up unchanged values
      Severity: Minor
      Found in classes/Gems/Tracker.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

      The class Gems_Tracker has 16 fields. Consider redesigning Gems_Tracker to keep the number of fields under 15.
      Open

      class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
      {
          const DB_DATE_FORMAT = 'yyyy-MM-dd';
          const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
      
      
      Severity: Minor
      Found in classes/Gems/Tracker.php by phpmd

      TooManyFields

      Since: 0.1

      Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

      Example

      class Person {
         protected $one;
         private $two;
         private $three;
         [... many more fields ...]
      }

      Source https://phpmd.org/rules/codesize.html#toomanyfields

      Method loadCompletedTokensBatch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function loadCompletedTokensBatch(\Gems_Task_TaskRunnerBatch $batch, $respondentId = null, $userId = null, $orgId = null, $quickCheck = false)
          {
              $userId = $this->_checkUserId($userId);
      
              $tokenSelect = $this->getTokenSelect(array('gto_id_token'));
      Severity: Minor
      Found in classes/Gems/Tracker.php - About 1 hr to fix

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

            public function loadCompletedTokensBatch(\Gems_Task_TaskRunnerBatch $batch, $respondentId = null, $userId = null, $orgId = null, $quickCheck = false)
            {
                $userId = $this->_checkUserId($userId);
        
                $tokenSelect = $this->getTokenSelect(array('gto_id_token'));
        Severity: Minor
        Found in classes/Gems/Tracker.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

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

            public function createRespondentTrack($respondentId, $organizationId, $trackId, $userId, $respTrackData = array(), array $trackFieldsData = array())
        Severity: Minor
        Found in classes/Gems/Tracker.php - About 45 mins to fix

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

              public function getTrackEngineList($extended = false, $userCreatableOnly = false)
              {
                  $results = array();
                  $dummyTrackData['gtr_id_track'] = 0;
          
          
          Severity: Minor
          Found in classes/Gems/Tracker.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 loadCompletedTokensBatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function loadCompletedTokensBatch(\Gems_Task_TaskRunnerBatch $batch, $respondentId = null, $userId = null, $orgId = null, $quickCheck = false)
          Severity: Minor
          Found in classes/Gems/Tracker.php - About 35 mins to fix

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

                public function getTrackEngine($trackData)
                {
                    if (is_array($trackData)) {
                        $trackId   = $trackData['gtr_id_track'];
                    } else {
            Severity: Minor
            Found in classes/Gems/Tracker.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 getSource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getSource($sourceData)
                {
                    if (is_array($sourceData)) {
                        $sourceId = $sourceData['gso_id_source'];
                    } else {
            Severity: Minor
            Found in classes/Gems/Tracker.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 getAllCodeFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getAllCodeFields()
                {
                    static $fields = false; // Using static so it will be refreshed once per request
            
                    if ($fields === false) {
            Severity: Minor
            Found in classes/Gems/Tracker.php - About 25 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 getToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getToken($tokenData)
                {
                    if (! $tokenData) {
                        throw new \Gems_Exception_Coding('Provide at least the token when requesting a token');
                    }
            Severity: Minor
            Found in classes/Gems/Tracker.php - About 25 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 getRespondentTrack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRespondentTrack($respTrackData)
                {
                    if (is_array($respTrackData)) {
                        $respTracksId = $respTrackData['gr2t_id_respondent_track'];
                    } else {
            Severity: Minor
            Found in classes/Gems/Tracker.php - About 25 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 synchronizeSources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function synchronizeSources($sourceId = null, $userId = null)
                {
                    $batch_id = 'source_synch' . ($sourceId ? '_' . $sourceId : '');
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            
            
            Severity: Minor
            Found in classes/Gems/Tracker.php - About 25 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

            The class Gems_Tracker has 1103 lines of code. Current threshold is 1000. Avoid really long classes.
            Open

            class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
            {
                const DB_DATE_FORMAT = 'yyyy-MM-dd';
                const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
            
            
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            The class Gems_Tracker has a coupling between objects value of 33. Consider to reduce the number of dependencies under 13.
            Open

            class Gems_Tracker extends \Gems_Loader_TargetLoaderAbstract implements \Gems_Tracker_TrackerInterface
            {
                const DB_DATE_FORMAT = 'yyyy-MM-dd';
                const DB_DATETIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
            
            
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Avoid unused local variables such as '$tokencount'.
            Open

                    $tokencount = 0;
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            UnusedLocalVariable

            Since: 0.2

            Detects when a local variable is declared and/or assigned, but not used.

            Example

            class Foo {
                public function doSomething()
                {
                    $i = 5; // Unused
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

            Avoid unused local variables such as '$dummyTrackData'.
            Open

                    $dummyTrackData['gtr_id_track'] = 0;
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            UnusedLocalVariable

            Since: 0.2

            Detects when a local variable is declared and/or assigned, but not used.

            Example

            class Foo {
                public function doSomething()
                {
                    $i = 5; // Unused
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

            Avoid unused local variables such as '$where'.
            Open

                    $where = implode(' ', $tokenSelect->getSelect()->getPart(\Zend_Db_Select::WHERE));
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            UnusedLocalVariable

            Since: 0.2

            Detects when a local variable is declared and/or assigned, but not used.

            Example

            class Foo {
                public function doSomething()
                {
                    $i = 5; // Unused
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

            TODO found
            Open

                    // TODO: this should be moved to \Gems_Tracker_Source_SourceInterface,
            Severity: Minor
            Found in classes/Gems/Tracker.php by fixme

            The parameter $batch_id is not named in camelCase.
            Open

                public function refreshTokenAttributes($batch_id, $cond = null)
                {
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            
                    if (! $batch->isLoaded()) {
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The parameter $args_array is not named in camelCase.
            Open

                public function getAskTokenForm($args_array = null)
                {
                    $args = \MUtil_Ra::args(func_get_args());
            
                    return $this->_loadClass('Form_AskTokenForm', true, array($args));
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            Avoid variables with short names like $db. Configured minimum length is 3.
            Open

                protected $db;
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            The parameter $batch_id is not named in camelCase.
            Open

                protected function processTokensBatch($batch_id, \Gems_Tracker_Token_TokenSelect $tokenSelect, $userId)
                {
                    $where = implode(' ', $tokenSelect->getSelect()->getPart(\Zend_Db_Select::WHERE));
            
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The parameter $batch_id is not named in camelCase.
            Open

                public function recalculateTokens($batch_id, $userId = null, $cond = null)
                {
                    $userId = $this->_checkUserId($userId);
                    $tokenSelect = $this->getTokenSelect(array('gto_id_token'));
                    $tokenSelect->andReceptionCodes(array())
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseParameterName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name parameters.

            Example

            class ClassName {
                public function doSomething($user_name) {
                }
            }

            Source

            The variable $batch_id is not named in camelCase.
            Open

                public function synchronizeSources($sourceId = null, $userId = null)
                {
                    $batch_id = 'source_synch' . ($sourceId ? '_' . $sourceId : '');
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            
            
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $batch_id is not named in camelCase.
            Open

                public function synchronizeSources($sourceId = null, $userId = null)
                {
                    $batch_id = 'source_synch' . ($sourceId ? '_' . $sourceId : '');
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            
            
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $batch_id is not named in camelCase.
            Open

                public function refreshTokenAttributes($batch_id, $cond = null)
                {
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            
                    if (! $batch->isLoaded()) {
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $batch_id is not named in camelCase.
            Open

                public function recalculateTokens($batch_id, $userId = null, $cond = null)
                {
                    $userId = $this->_checkUserId($userId);
                    $tokenSelect = $this->getTokenSelect(array('gto_id_token'));
                    $tokenSelect->andReceptionCodes(array())
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $batch_id is not named in camelCase.
            Open

                protected function processTokensBatch($batch_id, \Gems_Tracker_Token_TokenSelect $tokenSelect, $userId)
                {
                    $where = implode(' ', $tokenSelect->getSelect()->getPart(\Zend_Db_Select::WHERE));
            
                    $batch = $this->loader->getTaskRunnerBatch($batch_id);
            Severity: Minor
            Found in classes/Gems/Tracker.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            There are no issues that match your filters.

            Category
            Status