NeroReflex/Gishiki

View on GitHub

Showing 176 of 176 total issues

Avoid using undefined variables such as '::$structure' which will lead to PHP notices.
Open

        foreach (static::$structure['fields'] as $fieldName => &$fieldDefinition) {

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

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

    public function __construct(RequestInterface &$request, ResponseInterface &$response, Application $app = null)
    {
        //this is important, NEVER forget!
        parent::__construct($request, $response, $app);

Severity: Minor
Found in src/Core/MVC/Controller/Plugins/RequestDeserializer.php - About 1 hr to fix

    Method matchCheck has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function matchCheck($uriSplit, $urlSplit, array &$params) : bool
        {
            $result = false;
    
            if ((strlen($uriSplit) >= 7) && ($uriSplit[0] == '{') && ($uriSplit[strlen($uriSplit) - 1] == '}')) {
    Severity: Minor
    Found in src/Core/Router/MatchableRouteTrait.php - About 1 hr to fix

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

          public function serialize($format = self::JSON)
          {
              if (!is_integer($format)) {
                  throw new \InvalidArgumentException('Invalid serialization format');
              }
      Severity: Minor
      Found in src/Algorithms/Collections/SerializableCollection.php - About 1 hr to fix

        Method loadRelation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function loadRelation(Column &$column, $className, $propName)
            {
                if (!class_exists($className)) {
                    throw new ActiveRecordException("The class $className doesn't exists.", 109);
                }
        Severity: Minor
        Found in src/Core/MVC/Model/ActiveRecordStructureTrait.php - About 1 hr to fix

          Method matchURI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function matchURI($uri, $url, array &$matchedExpr, array &$matchedGet) : bool
              {
                  if (!is_string($url)) {
                      throw new \InvalidArgumentException("The URL must be given as a valid string");
                  }
          Severity: Minor
          Found in src/Core/Router/MatchableRouteTrait.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if ((strcmp($method, RouteInterface::GET) == 0) ||
                            (strcmp($method, RouteInterface::POST) == 0) ||
                            (strcmp($method, RouteInterface::PUT) == 0) ||
                            (strcmp($method, RouteInterface::DELETE) == 0) ||
                            (strcmp($method, RouteInterface::HEAD) == 0) ||
            Severity: Major
            Found in src/Core/Router/Router.php - About 1 hr to fix

              Function isFloat has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function isFloat($str) : bool
                  {
                      if (!self::isString($str)) {
                          return false;
                      }
              Severity: Minor
              Found in src/Algorithms/Strings/SimpleLexer.php - About 55 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 where has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function &where(SelectionCriteria $where) : SQLWrapperInterface
                  {
                      //execute the private function 'export'
                      $exportMethod = new \ReflectionMethod($where, 'export');
                      $exportMethod->setAccessible(true);
              Severity: Minor
              Found in src/Database/Adapters/Utils/SQLGenerator/SQLWrapper.php - About 55 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 limitOffsetOrderBy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function &limitOffsetOrderBy(ResultModifier $mod) : SQLWrapperInterface
                  {
                      //execute the private function 'export'
                      $exportMethod = new \ReflectionMethod($mod, 'export');
                      $exportMethod->setAccessible(true);
              Severity: Minor
              Found in src/Database/Adapters/Utils/SQLGenerator/SQLWrapper.php - About 45 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 matchURI has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function matchURI($uri, $url, array &$matchedExpr, array &$matchedGet) : bool
                  {
                      if (!is_string($url)) {
                          throw new \InvalidArgumentException("The URL must be given as a valid string");
                      }
              Severity: Minor
              Found in src/Core/Router/MatchableRouteTrait.php - About 45 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 paramCheck has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected static function paramCheck($urlSplit, $type) : bool
                  {
                      if ((!is_int($type)) || ($type < 0) || ($type > 4)) {
                          throw new RouterException("Invalid parameter type", 100);
                      }
              Severity: Minor
              Found in src/Core/Router/MatchableRouteTrait.php - About 45 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 loadErrorHandlers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function loadErrorHandlers($method) : array
                  {
                      $errorHandlers = [];
              
                      foreach ($this->routes[$method] as &$currentRoute) {
              Severity: Minor
              Found in src/Core/Router/Router.php - About 45 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 class Application has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
              Open

              final class Application
              {
                  use ApplicationDatabaseTrait;
                  use ApplicationLoggerTrait;
              
              
              Severity: Minor
              Found in src/Core/Application.php by phpmd

              CouplingBetweenObjects

              Since: 1.1.0

              A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

              Example

              class Foo {
                  /**
                   * @var \foo\bar\X
                   */
                  private $x = null;
              
                  /**
                   * @var \foo\bar\Y
                   */
                  private $y = null;
              
                  /**
                   * @var \foo\bar\Z
                   */
                  private $z = null;
              
                  public function setFoo(\Foo $foo) {}
                  public function setBar(\Bar $bar) {}
                  public function setBaz(\Baz $baz) {}
              
                  /**
                   * @return \SplObjectStorage
                   * @throws \OutOfRangeException
                   * @throws \InvalidArgumentException
                   * @throws \ErrorException
                   */
                  public function process(\Iterator $it) {}
              
                  // ...
              }

              Source https://phpmd.org/rules/design.html#couplingbetweenobjects

              The class Route has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
              Open

              class Route implements RouteInterface
              {
                  use MatchableRouteTrait;
              
                  /**
              Severity: Minor
              Found in src/Core/Router/Route.php by phpmd

              CouplingBetweenObjects

              Since: 1.1.0

              A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

              Example

              class Foo {
                  /**
                   * @var \foo\bar\X
                   */
                  private $x = null;
              
                  /**
                   * @var \foo\bar\Y
                   */
                  private $y = null;
              
                  /**
                   * @var \foo\bar\Z
                   */
                  private $z = null;
              
                  public function setFoo(\Foo $foo) {}
                  public function setBar(\Bar $bar) {}
                  public function setBaz(\Baz $baz) {}
              
                  /**
                   * @return \SplObjectStorage
                   * @throws \OutOfRangeException
                   * @throws \InvalidArgumentException
                   * @throws \ErrorException
                   */
                  public function process(\Iterator $it) {}
              
                  // ...
              }

              Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                  public function __invoke(RequestInterface &$request, ResponseInterface &$response, GenericCollection &$arguments, $controllerArgs = [], Application $app = null)
              Severity: Minor
              Found in src/Core/Router/Route.php - About 35 mins to fix

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

                    public function __construct(RequestInterface &$controllerRequest, ResponseInterface &$controllerResponse, GenericCollection &$controllerArguments, array &$plugins, Application $app = null)
                Severity: Minor
                Found in src/Core/MVC/Controller/Controller.php - About 35 mins to fix

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

                      public function __invoke(RequestInterface &$request, ResponseInterface &$response, GenericCollection &$arguments, $controllerArgs = [], Application $app = null);
                  Severity: Minor
                  Found in src/Core/Router/RouteInterface.php - About 35 mins to fix

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

                        public static function pbkdf2($password, $salt, $keyLength, $count, $algorithm = self::SHA256)
                    Severity: Minor
                    Found in src/Security/Hashing/Algorithm.php - About 35 mins to fix

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

                          private function initTransitionSchema()
                          {
                              //table must have been already correctly parsed, so I know data is well-formed
                              if (!ActiveRecordTables::isRegistered(static::class)) {
                                  throw new ActiveRecordException("Table definition for the current ActiveRecord object is missing.", 300);
                      Severity: Minor
                      Found in src/Core/MVC/Model/ActiveRecordSerializationTrait.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

                      Severity
                      Category
                      Status
                      Source
                      Language