GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Tracker/RespondentTrack.php

Summary

Maintainability
F
1 wk
Test Coverage
F
53%

File RespondentTrack.php has 928 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *
 * @package    Gems
Severity: Major
Found in classes/Gems/Tracker/RespondentTrack.php - About 2 days to fix

    Gems_Tracker_RespondentTrack has 65 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
    {
        use DbTranslateUtilTrait;
        
        /**
    Severity: Major
    Found in classes/Gems/Tracker/RespondentTrack.php - About 1 day to fix

      Function assignTokensToRelations has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function assignTokensToRelations()
          {
              // Find out if we have relation fields and return when none exists in this track
              $relationFields = $this->getTrackEngine()->getFieldsOfType('relation');
              if (empty($relationFields)) {
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.php - About 3 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_RespondentTrack has 20 public methods. Consider refactoring Gems_Tracker_RespondentTrack to keep number of public methods under 10.
      Open

      class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
      {
          use DbTranslateUtilTrait;
          
          /**

      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

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

      class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
      {
          use DbTranslateUtilTrait;
          
          /**

      The class Gems_Tracker_RespondentTrack has 26 non-getter- and setter-methods. Consider refactoring Gems_Tracker_RespondentTrack to keep number of methods under 25.
      Open

      class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
      {
          use DbTranslateUtilTrait;
          
          /**

      TooManyMethods

      Since: 0.1

      A class with too many 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'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

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

          public function setReceptionCode($code, $comment, $userId)
          {
              // Make sure it is a \Gems_Util_ReceptionCode object
              if (! $code instanceof \Gems_Util_ReceptionCode) {
                  $code = $this->util->getReceptionCode($code);
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.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

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

          protected function _mergeFieldValues(array $newFieldData, array $oldFieldData, \Gems_Tracker_Engine_TrackEngineInterface $trackEngine)
          {
              $fieldDef = $trackEngine->getFieldsDefinition();
              $fieldMap = $fieldDef->getFieldCodes() + $fieldDef->getManualFields();
              $output   = array();
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.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

      Function getCurrentRound has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getCurrentRound()
          {
              $isStop = false;
              $today  = new \Zend_Date();
              $tokens = $this->getTokens();
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.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

      Function getDate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getDate($fieldName)
          {
              if (isset($this->_respTrackData[$fieldName])) {
                  $date = $this->_respTrackData[$fieldName];
              } else {
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.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 assignTokensToRelations has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function assignTokensToRelations()
          {
              // Find out if we have relation fields and return when none exists in this track
              $relationFields = $this->getTrackEngine()->getFieldsOfType('relation');
              if (empty($relationFields)) {
      Severity: Minor
      Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

        Method handleRoundCompletion has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handleRoundCompletion($token, $userId)
            {
                if (! $token instanceof \Gems_Tracker_Token) {
                    $token = $this->tracker->getToken($token);
                }
        Severity: Minor
        Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

          Method handleBeforeFieldUpdate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleBeforeFieldUpdate(array $fieldData)
              {
                  static $running = array();
          
                  // Process any events
          Severity: Minor
          Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

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

                protected function _updateTrack(array $values, $userId  = null)
                {
                    if (null === $userId) {
                        $userId = $this->currentUser->getUserId();
                    }
            Severity: Minor
            Found in classes/Gems/Tracker/RespondentTrack.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

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

                public function getTokens($refresh = false)
                {
                    if (! $this->_tokens || $refresh) {
                        if ($refresh) {
                            $this->_firstToken = null;
            Severity: Minor
            Found in classes/Gems/Tracker/RespondentTrack.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 calculateEndDate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function calculateEndDate()
                {
                    // Exclude the tokens whose end date is calculated from the track end date
                    $excludeWheres[] = sprintf(
                            "gro_valid_for_source = '%s' AND gro_valid_for_field = 'gr2t_end_date'",
            Severity: Minor
            Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

              Method _mergeFieldValues has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function _mergeFieldValues(array $newFieldData, array $oldFieldData, \Gems_Tracker_Engine_TrackEngineInterface $trackEngine)
                  {
                      $fieldDef = $trackEngine->getFieldsDefinition();
                      $fieldMap = $fieldDef->getFieldCodes() + $fieldDef->getManualFields();
                      $output   = array();
              Severity: Minor
              Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

                Method handleFieldUpdate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function handleFieldUpdate(array $oldFieldData = null)
                    {
                        static $running = array();
                
                        // Process any events
                Severity: Minor
                Found in classes/Gems/Tracker/RespondentTrack.php - About 1 hr to fix

                  Function handleRoundCompletion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleRoundCompletion($token, $userId)
                      {
                          if (! $token instanceof \Gems_Tracker_Token) {
                              $token = $this->tracker->getToken($token);
                          }
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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

                  Function restoreTokens has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function restoreTokens(\Gems_Util_ReceptionCode $oldCode, \Gems_Util_ReceptionCode $newCode) {
                          $count = 0;
                  
                          if (!$oldCode->isSuccess() && $newCode->isSuccess()) {
                              foreach ($this->getTokens() as $token) {
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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

                  The class Gems_Tracker_RespondentTrack has 59 public methods and attributes. Consider reducing the number of public items to less than 45.
                  Open

                  class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
                  {
                      use DbTranslateUtilTrait;
                      
                      /**

                  ExcessivePublicCount

                  Since: 0.1

                  A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

                  Example

                  public class Foo {
                      public $value;
                      public $something;
                      public $var;
                      // [... more more public attributes ...]
                  
                      public function doWork() {}
                      public function doMoreWork() {}
                      public function doWorkAgain() {}
                      // [... more more public methods ...]
                  }

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

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

                      public function getRoundAfterAppointmentId($roundId)
                      {
                          $this->_ensureFieldData();
                          $this->_ensureRounds();
                  
                  
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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 getActiveRoundToken has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getActiveRoundToken($roundId, \Gems_Tracker_Token $token = null)
                      {
                          if ((null !== $token) && $token->hasSuccesCode()) {
                              // Cache the token
                              //
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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 handleBeforeFieldUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleBeforeFieldUpdate(array $fieldData)
                      {
                          static $running = array();
                  
                          // Process any events
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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 handleFieldUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function handleFieldUpdate(array $oldFieldData = null)
                      {
                          static $running = array();
                  
                          // Process any events
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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 getCodeFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getCodeFields()
                      {
                          $fieldDef = $this->getTrackEngine()->getFieldsDefinition();
                          $codes    = $this->tracker->getAllCodeFields();
                          $results  = array_fill_keys($codes, null);
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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 checkRegistryRequestsAnswers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function checkRegistryRequestsAnswers()
                      {
                          $this->initDbTranslations();
                          
                          if ($this->_respTrackData) {
                  Severity: Minor
                  Found in classes/Gems/Tracker/RespondentTrack.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_RespondentTrack has 1653 lines of code. Current threshold is 1000. Avoid really long classes.
                  Open

                  class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
                  {
                      use DbTranslateUtilTrait;
                      
                      /**

                  The method assignTokensToRelations() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                  Open

                      public function assignTokensToRelations()
                      {
                          // Find out if we have relation fields and return when none exists in this track
                          $relationFields = $this->getTrackEngine()->getFieldsOfType('relation');
                          if (empty($relationFields)) {

                  CyclomaticComplexity

                  Since: 0.1

                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                  Example

                  // Cyclomatic Complexity = 11
                  class Foo {
                  1   public function example() {
                  2       if ($a == $b) {
                  3           if ($a1 == $b1) {
                                  fiddle();
                  4           } elseif ($a2 == $b2) {
                                  fiddle();
                              } else {
                                  fiddle();
                              }
                  5       } elseif ($c == $d) {
                  6           while ($c == $d) {
                                  fiddle();
                              }
                  7        } elseif ($e == $f) {
                  8           for ($n = 0; $n < $h; $n++) {
                                  fiddle();
                              }
                          } else {
                              switch ($z) {
                  9               case 1:
                                      fiddle();
                                      break;
                  10              case 2:
                                      fiddle();
                                      break;
                  11              case 3:
                                      fiddle();
                                      break;
                                  default:
                                      fiddle();
                                      break;
                              }
                          }
                      }
                  }

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

                  The method setReceptionCode() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                  Open

                      public function setReceptionCode($code, $comment, $userId)
                      {
                          // Make sure it is a \Gems_Util_ReceptionCode object
                          if (! $code instanceof \Gems_Util_ReceptionCode) {
                              $code = $this->util->getReceptionCode($code);

                  CyclomaticComplexity

                  Since: 0.1

                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                  Example

                  // Cyclomatic Complexity = 11
                  class Foo {
                  1   public function example() {
                  2       if ($a == $b) {
                  3           if ($a1 == $b1) {
                                  fiddle();
                  4           } elseif ($a2 == $b2) {
                                  fiddle();
                              } else {
                                  fiddle();
                              }
                  5       } elseif ($c == $d) {
                  6           while ($c == $d) {
                                  fiddle();
                              }
                  7        } elseif ($e == $f) {
                  8           for ($n = 0; $n < $h; $n++) {
                                  fiddle();
                              }
                          } else {
                              switch ($z) {
                  9               case 1:
                                      fiddle();
                                      break;
                  10              case 2:
                                      fiddle();
                                      break;
                  11              case 3:
                                      fiddle();
                                      break;
                                  default:
                                      fiddle();
                                      break;
                              }
                          }
                      }
                  }

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

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

                  class Gems_Tracker_RespondentTrack extends \Gems_Registry_TargetAbstract
                  {
                      use DbTranslateUtilTrait;
                      
                      /**

                  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

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

                      protected function _ensureRespondentData()
                      {
                          if (! isset($this->_respTrackData['grs_id_user'], $this->_respTrackData['gr2o_id_user'], $this->_respTrackData['gco_code'])) {
                              $sql = "SELECT *
                                  FROM gems__respondents INNER JOIN
                  Severity: Major
                  Found in classes/Gems/Tracker/RespondentTrack.php and 1 other location - About 2 hrs to fix
                  classes/Gems/Tracker/Token.php on lines 222..242

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

                  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 excessively long variable names like $respondentTrackFieldEvent. Keep variable name length under 20.
                  Open

                          $respondentTrackFieldEvent = new RespondentTrackFieldEvent($this, $this->currentUser->getUserId());

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Avoid excessively long variable names like $beforeFieldUpdateEvent. Keep variable name length under 20.
                  Open

                          $beforeFieldUpdateEvent = $trackEngine->getFieldBeforeUpdateEvent();

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Avoid excessively long variable names like $_tablesForTranslations. Keep variable name length under 20.
                  Open

                      protected $_tablesForTranslations = [
                          'gems__respondent2track' => 'gr2t_id_respondent_track',
                          'gems__tracks' => 'gtr_id_track',
                          ];

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  There are no issues that match your filters.

                  Category
                  Status