amtgard/ORK3

View on GitHub
system/lib/phpqrcode/qrmask.php

Summary

Maintainability
F
2 wks
Test Coverage

Function evaluateSymbol has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

        public function evaluateSymbol($width, $frame)
        {
            $head = 0;
            $demerit = 0;

Severity: Minor
Found in system/lib/phpqrcode/qrmask.php - About 6 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 calcN1N3 has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        public function calcN1N3($length)
        {
            $demerit = 0;

            for($i=0; $i<$length; $i++) {
Severity: Minor
Found in system/lib/phpqrcode/qrmask.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

Method evaluateSymbol has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function evaluateSymbol($width, $frame)
        {
            $head = 0;
            $demerit = 0;

Severity: Major
Found in system/lib/phpqrcode/qrmask.php - About 2 hrs to fix

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

            public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) 
            {
                $b = 0;
                $bitMask = array();
                
    Severity: Minor
    Found in system/lib/phpqrcode/qrmask.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 writeFormatInformation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            public function writeFormatInformation($width, &$frame, $mask, $level)
            {
                $blacks = 0;
                $format =  QRspec::getFormatInfo($mask, $level);
    
    
    Severity: Minor
    Found in system/lib/phpqrcode/qrmask.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 writeFormatInformation has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function writeFormatInformation($width, &$frame, $mask, $level)
            {
                $blacks = 0;
                $format =  QRspec::getFormatInfo($mask, $level);
    
    
    Severity: Minor
    Found in system/lib/phpqrcode/qrmask.php - About 1 hr to fix

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

              public function mask($width, $frame, $level)
              {
                  $minDemerit = PHP_INT_MAX;
                  $bestMaskNum = 0;
                  $bestMask = array();
      Severity: Minor
      Found in system/lib/phpqrcode/qrmask.php - About 1 hr to fix

        Method makeMaskNo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) 
                {
                    $b = 0;
                    $bitMask = array();
                    
        Severity: Minor
        Found in system/lib/phpqrcode/qrmask.php - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                      } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) {
                                          $demerit += N3;
                                      }
          Severity: Major
          Found in system/lib/phpqrcode/qrmask.php - About 45 mins to fix

            Method makeMaskNo has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) 
            Severity: Minor
            Found in system/lib/phpqrcode/qrmask.php - About 35 mins to fix

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

                      private function generateMaskNo($maskNo, $width, $frame)
                      {
                          $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
                          
                          for($y=0; $y<$width; $y++) {
              Severity: Minor
              Found in system/lib/phpqrcode/qrmask.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 mask has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      public function mask($width, $frame, $level)
                      {
                          $minDemerit = PHP_INT_MAX;
                          $bestMaskNum = 0;
                          $bestMask = array();
              Severity: Minor
              Found in system/lib/phpqrcode/qrmask.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

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

                  class QRmask {
                  
                      public $runLength = array();
                      
                      //----------------------------------------------------------------------
              Severity: Major
              Found in system/lib/phpqrcode/qrmask.php and 1 other location - About 2 wks to fix
              system/lib/phpqrcode/phpqrcode.php on lines 2505..2800

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

              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