canax/router

View on GitHub

Showing 28 of 66 total issues

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

    private function checkPartAsArgument($rulePart, $queryPart, &$args)
    {
        if (substr($rulePart, -1) == "}"
            && !is_null($queryPart)
        ) {
Severity: Minor
Found in src/Route/RouteMatcher.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

Avoid too many return statements within this method.
Open

                return $this->handleAsInvocableClass($action);
Severity: Major
Found in src/Route/RouteHandler.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return false;
    Severity: Major
    Found in src/Route/RouteMatcher.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return $this->handleInternal("500", $e->getMessage());
      Severity: Major
      Found in src/Route/Router.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $this->handleInternal("500", $e->getMessage());
        Severity: Major
        Found in src/Route/Router.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return "not found";
          Severity: Major
          Found in src/Route/RouteHandler.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $this->handleUsingDi($action, $arguments, $di);
            Severity: Major
            Found in src/Route/RouteHandler.php - About 30 mins to fix

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

                  public function addRoutes(array $routes) : object
                  {
                      if (!(isset($routes["routes"]) && is_array($routes["routes"]))) {
                          throw new ConfigurationException("No routes found, missing key 'routes' in configuration array.");
                      }
              Severity: Minor
              Found in src/Route/Router.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

              Severity
              Category
              Status
              Source
              Language