werneckbh/qr-code

View on GitHub
src/QR_Code/Encoder/Mask.php

Summary

Maintainability
D
2 days
Test Coverage

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

    public function evaluateSymbol (int $width, array $frame)
    {
        $head = 0;
        $demerit = 0;
Severity: Minor
Found in src/QR_Code/Encoder/Mask.php - About 5 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 21 (exceeds 5 allowed). Consider refactoring.
Open

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

        for ($i = 0; $i < $length; $i++) {
Severity: Minor
Found in src/QR_Code/Encoder/Mask.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 evaluateSymbol has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function evaluateSymbol (int $width, array $frame)
    {
        $head = 0;
        $demerit = 0;
Severity: Major
Found in src/QR_Code/Encoder/Mask.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 = [];
    
    Severity: Minor
    Found in src/QR_Code/Encoder/Mask.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 (int $width, array &$frame, int $mask, int $level) : int
        {
            $blacks = 0;
            $format = Specifications::getFormatInfo($mask, $level);
    
    Severity: Minor
    Found in src/QR_Code/Encoder/Mask.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 (int $width, array &$frame, int $mask, int $level) : int
        {
            $blacks = 0;
            $format = Specifications::getFormatInfo($mask, $level);
    
    Severity: Minor
    Found in src/QR_Code/Encoder/Mask.php - About 1 hr to fix

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

          public function mask (int $width, array $frame, int $level) : array
          {
              $minDemerit = PHP_INT_MAX;
              $bestMaskNum = 0;
              $bestMask = [];
      Severity: Minor
      Found in src/QR_Code/Encoder/Mask.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 = [];
        
        Severity: Minor
        Found in src/QR_Code/Encoder/Mask.php - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (($this->runLength[$i - 3] < 0) || ($this->runLength[$i - 3] >= (4 * $fact))) {
                                      $demerit += N3;
                                  } elseif ((($i + 3) >= $length) || ($this->runLength[$i + 3] >= (4 * $fact))) {
                                      $demerit += N3;
                                  }
          Severity: Major
          Found in src/QR_Code/Encoder/Mask.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 src/QR_Code/Encoder/Mask.php - About 35 mins to fix

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

                  private function generateMaskNo ($maskNo, int $width, array $frame) : array
                  {
                      $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
              
                      for ($y = 0; $y < $width; $y++) {
              Severity: Minor
              Found in src/QR_Code/Encoder/Mask.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 (int $width, array $frame, int $level) : array
                  {
                      $minDemerit = PHP_INT_MAX;
                      $bestMaskNum = 0;
                      $bestMask = [];
              Severity: Minor
              Found in src/QR_Code/Encoder/Mask.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

              There are no issues that match your filters.

              Category
              Status