chippyash/Matrix

View on GitHub

Showing 64 of 64 total issues

The method __construct has a boolean flag argument $normalize, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function __construct($source, $complete = false, $normalize= false, $normalizeDefault = null)
Severity: Minor
Found in src/Chippyash/Matrix/Matrix.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method toMatrix has a boolean flag argument $rebase, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function toMatrix($rebase = true)

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method equality has a boolean flag argument $strict, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function equality(Matrix $mB, $strict = true)
Severity: Minor
Found in src/Chippyash/Matrix/Matrix.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid too many return statements within this method.
Open

        return ($direction == 1 ? $ret : $fReflect($ret, Reflect::REFL_Y));
Severity: Major
Found in src/Chippyash/Matrix/Transformation/Shift.php - About 30 mins to fix

    The method __construct has a boolean flag argument $complete, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function __construct($source, $complete = false, $normalize= false, $normalizeDefault = null)
    Severity: Minor
    Found in src/Chippyash/Matrix/Matrix.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid too many return statements within this method.
    Open

            return (
                $numRows > 0
                    ? $this->addRows($interim, $numRows, $defValue)
                    : $this->reduceRows($interim, abs($numRows))
            );
    Severity: Major
    Found in src/Chippyash/Matrix/Transformation/Resize.php - About 30 mins to fix

      Missing class import via use statement (line '81', column '23').
      Open

                  throw new \Exception('Debug parameter is not an array or a matrix');
      Severity: Minor
      Found in src/Chippyash/Matrix/Traits/Debug.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '335', column '19').
      Open

              throw new \InvalidArgumentException(self::ERR_INVALID_OP_NAME);
      Severity: Minor
      Found in src/Chippyash/Matrix/Matrix.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '254', column '27').
      Open

                      throw new \BadMethodCallException();
      Severity: Minor
      Found in src/Chippyash/Matrix/Matrix.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

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

          protected function doTransform(Matrix $mA, $extra = null)
          {
              if ($mA->is('empty')) {
                  return new Matrix(array());
              }
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Rowslice.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)
          {
              if (is_null($extra)) {
                  throw new TransformationException('Reflection plane not specified');
              } else {
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Reflect.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 test has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function test($attribute)
          {
              if (is_string($attribute)) {
                  $attribute = ucfirst(strtolower($attribute));
                  $class = self::NS_ATTRIBUTE. $attribute;
      Severity: Minor
      Found in src/Chippyash/Matrix/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)
          {
              if ($mA->is('empty')) {
                  return new Matrix([]);
              }
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Colreduce.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)
          {
              if ($mA->is('empty')) {
                  return new Matrix([]);
              }
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Cofactor.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)
          {
              if ($mA->is('empty')) {
                  return new Matrix(array());
              }
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Colslice.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)
          {
              if (is_null($extra)) {
                  $extra = self::ROT_90;
              } else {
      Severity: Minor
      Found in src/Chippyash/Matrix/Transformation/Rotate.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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $minRow = min(array_keys($source));
                  if (!is_array($source[$minRow])) {
                      $this->store(array($source));
                  } else {
      Severity: Minor
      Found in src/Chippyash/Matrix/Matrix.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $this->store($source);
                  }
      Severity: Minor
      Found in src/Chippyash/Matrix/Matrix.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method test uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      throw new \BadMethodCallException();
                  }
      Severity: Minor
      Found in src/Chippyash/Matrix/Matrix.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid unused parameters such as '$extra'.
      Open

          protected function doTransform(Matrix $mA, $extra = null)

      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

      Severity
      Category
      Status
      Source
      Language