chippyash/Math-Matrix

View on GitHub

Showing 60 of 183 total issues

Avoid too many return statements within this method.
Open

                return TypeFactory::createInt(0);
Severity: Major
Found in src/Chippyash/Math/Matrix/Traits/ConvertNumberToNumeric.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                        return ComplexTypeFactory::create($scalar);
    Severity: Major
    Found in src/Chippyash/Math/Matrix/Traits/CreateCorrectScalarType.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return RationalTypeFactory::create(0, 1);
      Severity: Major
      Found in src/Chippyash/Math/Matrix/Traits/ConvertNumberToRational.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return RationalTypeFactory::create($scalar);
        Severity: Major
        Found in src/Chippyash/Math/Matrix/Traits/CreateCorrectScalarType.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return ComplexTypeFactory::create(($value ? 1 : 0), 0);
          Severity: Major
          Found in src/Chippyash/Math/Matrix/Traits/ConvertNumberToComplex.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return TypeFactory::createInt($scalar);
            Severity: Major
            Found in src/Chippyash/Math/Matrix/Traits/CreateCorrectScalarType.php - About 30 mins to fix

              Function is has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function is(Matrix $mA)
                  {
                      try {
                          $this->assertMatrixIsNumeric($mA)
                               ->assertMatrixIsSquare($mA);
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Attribute/IsMarkov.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 doTransform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function doTransform(Matrix $mA, $extra = null)
                  {
                      $this->assertMatrixIsNumeric($mA);
              
                      if (!array_key_exists('start', $extra)) {
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Transformation/MarkovRandomWalk.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 getDeterminant has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getDeterminant(NumericMatrix $mA)
                  {
                      switch ($this->method) {
                          case self::METHOD_AUTO;
                              if ($mA->rows() <= self::$luLimit) {
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Derivative/Determinant.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 doComputation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function doComputation(NumericMatrix $mA, NumericMatrix $mB)
                  {
                      $size = max([$mA->columns(), $mA->rows(), $mB->columns(), $mB->rows()]);
                      $product = (new ZMatrix())->create([$size, $size])->toArray();
                      $dA = $mA->toArray();
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Computation/Mul/Matrix.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 doTransform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function doTransform(Matrix $mA, $extra = null)
                  {
                      $this->assertMatrixIsNumeric($mA);
              
                      if ($mA->is('empty')) {
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Transformation/Invert.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 product has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function product($productName)
                  {
                      if (!array_key_exists($productName, $this->products)) {
                          throw new \InvalidArgumentException($productName);
                      }
              Severity: Minor
              Found in src/Chippyash/Math/Matrix/Decomposition/AbstractDecomposition.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 method LUDecomposition() has an NPath complexity of 434. The configured NPath complexity threshold is 200.
              Open

                  protected function LUDecomposition(NumericMatrix $mA)
                  {
                      // Use a "left-looking", dot-product, Crout/Doolittle algorithm.
                      $LU = $mA->toArray();
                      $m = $this->rows = $mA->rows();

              NPathComplexity

              Since: 0.1

              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

              Example

              class Foo {
                  function bar() {
                      // lots of complicated code
                  }
              }

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

              The method createCorrectScalarType() has an NPath complexity of 3040. The configured NPath complexity threshold is 200.
              Open

                  protected function createCorrectScalarType(NumericMatrix $originalMatrix , $scalar)
                  {
                      if ($scalar instanceof NumericTypeInterface) {
                          if ($originalMatrix instanceof RationalMatrix) {
                              return $scalar->asRational();

              NPathComplexity

              Since: 0.1

              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

              Example

              class Foo {
                  function bar() {
                      // lots of complicated code
                  }
              }

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

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

                  protected function convertNumberToRational($value)
                  {
                      if($value instanceof NumericTypeInterface) {
                          return $value->asRational();
                      }

              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 format() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
              Open

                  public function format(Matrix $mA, array $options = array())
                  {
                      if (!$mA instanceof NumericMatrix) {
                          throw new \InvalidArgumentException('Matrix is not NumericMatrix');
                      }

              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 createCorrectScalarType() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10.
              Open

                  protected function createCorrectScalarType(NumericMatrix $originalMatrix , $scalar)
                  {
                      if ($scalar instanceof NumericTypeInterface) {
                          if ($originalMatrix instanceof RationalMatrix) {
                              return $scalar->asRational();

              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 convertNumberToNumeric() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
              Open

                  protected function convertNumberToNumeric($value)
                  {
                      switch(gettype($value)) {
                          case 'integer':
                              return TypeFactory::createInt($value);

              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 decompose() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
              Open

                  public function decompose(NumericMatrix $mA, $extra = null)
                  {
                      $this->assertParameterIsMatrix($extra, 'Parameter extra is not a matrix')
                              ->assertMatrixIsNumeric($extra, 'Parameter extra is not a numeric matrix')
                              ->assertMatrixIsSquare($mA,

              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 LUDecomposition() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
              Open

                  protected function LUDecomposition(NumericMatrix $mA)
                  {
                      // Use a "left-looking", dot-product, Crout/Doolittle algorithm.
                      $LU = $mA->toArray();
                      $m = $this->rows = $mA->rows();

              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

              Severity
              Category
              Status
              Source
              Language