GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Util/TokenData.php

Summary

Maintainability
D
2 days
Test Coverage
F
1%

File TokenData.php has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *
 * @package    Gems
Severity: Minor
Found in classes/Gems/Util/TokenData.php - About 5 hrs to fix

    Gems_Util_TokenData has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Gems_Util_TokenData extends \MUtil_Translate_TranslateableAbstract
    {
        /**
         *
         * @var \Gems_User_User
    Severity: Minor
    Found in classes/Gems/Util/TokenData.php - About 3 hrs to fix

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

      class Gems_Util_TokenData extends \MUtil_Translate_TranslateableAbstract
      {
          /**
           *
           * @var \Gems_User_User
      Severity: Minor
      Found in classes/Gems/Util/TokenData.php by phpmd

      Method getStatusIcons has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getStatusIcons()
          {
              static $status;
      
              if (is_null($status)) {
      Severity: Minor
      Found in classes/Gems/Util/TokenData.php - About 1 hr to fix

        Function getTokenAskButton has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTokenAskButton($tokenId, $tokenStatus, $staffToken, $keepCaps)
            {
                if ('O' == $tokenStatus || 'P' == $tokenStatus) {
                    if ($staffToken) {
                        $menuItem = $this->_getAskMenuItem();
        Severity: Minor
        Found in classes/Gems/Util/TokenData.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 getTokenStatusLink has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function getTokenStatusLink($tokenId, $tokenStatus, $patientNr, $roundDescr, $surveyName, $result)
        Severity: Minor
        Found in classes/Gems/Util/TokenData.php - About 45 mins to fix

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

              public function getTokenStatusTitle($tokenId, $tokenStatus, $patientNr, $roundDescr, $surveyName, $result)
          Severity: Minor
          Found in classes/Gems/Util/TokenData.php - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                            return 'waiting';
            Severity: Major
            Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return 'open';
              Severity: Major
              Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return 'grc_success = 1 AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) AND gto_in_source = 1';
                Severity: Major
                Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return 'empty';
                  Severity: Major
                  Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return 'grc_success = 1 AND gto_completion_time IS NULL AND gto_in_source = 0 AND gto_valid_until < CURRENT_TIMESTAMP';
                    Severity: Major
                    Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return 'grc_success = 1 AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) AND gto_in_source = 0';
                      Severity: Major
                      Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return 'unknown';
                        Severity: Major
                        Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return 'grc_success = 1 AND gto_completion_time IS NULL AND gto_in_source = 1 AND gto_valid_until < CURRENT_TIMESTAMP';
                          Severity: Major
                          Found in classes/Gems/Util/TokenData.php - About 30 mins to fix

                            Avoid unused parameters such as '$addDescription'.
                            Open

                                public function getTokenStatusDescriptionForBridge(\MUtil_Model_Bridge_TableBridgeAbstract $bridge, $addDescription = false)
                            Severity: Minor
                            Found in classes/Gems/Util/TokenData.php by phpmd

                            UnusedFormalParameter

                            Since: 0.2

                            Avoid passing parameters to methods or constructors and then not using those parameters.

                            Example

                            class Foo
                            {
                                private function bar($howdy)
                                {
                                    // $howdy is not used
                                }
                            }

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

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

                                    $status = array(
                                        'U' => $this->_('Valid from date unknown'),
                                        'W' => $this->_('Valid from date in the future'),
                                        'O' => $this->_('Open - can be answered now'),
                                        'P' => $this->_('Open - partially answered'),
                            Severity: Minor
                            Found in classes/Gems/Util/TokenData.php and 1 other location - About 45 mins to fix
                            classes/Gems/Agenda/Filter/FieldLikeModelDependency.php on lines 79..88

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status