brokencube/circuit

View on GitHub

Showing 67 of 67 total issues

Avoid excessively long variable names like $defaultExceptionHandler. Keep variable name length under 20.
Open

    public $defaultExceptionHandler = null;
Severity: Minor
Found in src/Router.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $previousMiddlewareStack. Keep variable name length under 20.
Open

        $previousMiddlewareStack = $this->middlewareStack;
Severity: Minor
Found in src/RouteCollector.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(Request $request) : Response
    {
        // Try and run the next middleware
        $next = next($this->prerouteMiddleware);
        if ($next instanceof Middleware) {
Severity: Minor
Found in src/Router.php - About 1 hr to fix

    Method process has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(Request $request) : Response
        {
            $router = $request->attributes->get('router');
            
            $next = next($this->middlewareStack);
    Severity: Minor
    Found in src/HandlerContainer.php - About 1 hr to fix

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

              $param->args = $newparams;
      Severity: Minor
      Found in src/Middleware/ParameterMatcher.php by phpmd

      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

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

                      ['error' => $e->getStatusCode() . ' ' . Response::$statusTexts[$e->getStatusCode()] ],

      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

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

                  $e->getStatusCode() . ' ' . Response::$statusTexts[$e->getStatusCode()],

      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

      Function process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process(Request $request, Delegate $delegate) : Response
          {
              $params = $request->attributes->get('controller');
              $args = $params->args;
              
      Severity: Minor
      Found in src/Middleware/ParameterMatcher.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

      Avoid variables with short names like $e. Configured minimum length is 3.
      Open

          public function handle(Exception $e, Request $request) : Response;
      Severity: Minor
      Found in src/Interfaces/ExceptionHandler.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $e. Configured minimum length is 3.
      Open

          public function handle(Exception $e, Request $request) : Response

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $e. Configured minimum length is 3.
      Open

          protected function handleException(\Throwable $e, Request $request) : Response
      Severity: Minor
      Found in src/Router.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

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

      class Router implements Delegate, LoggerAwareInterface
      {
          use LoggerAwareTrait;
          
          const CACHE_KEY = 'routes_v3';
      Severity: Minor
      Found in src/Router.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct($route, $class, $method, $args, Container $container)
      Severity: Minor
      Found in src/ControllerParams.php - About 35 mins to fix

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

            public function process(Request $request) : Response
            {
                $router = $request->attributes->get('router');
                
                $next = next($this->middlewareStack);
        Severity: Minor
        Found in src/HandlerContainer.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

        Missing class import via use statement (line '209', column '25').
        Open

                    return (new \Circuit\ExceptionHandler\DefaultHandler)->handle($e, $request);
        Severity: Minor
        Found in src/Router.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 '259', column '23').
        Open

                    throw new \UnexpectedValueException("No middleware registered under name '{$name}'");
        Severity: Minor
        Found in src/Router.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

        Avoid too many return statements within this method.
        Open

                    return new Response(
                        $return,
                        Response::HTTP_OK,
                        array('content-type' => 'text/html')
                    );
        Severity: Major
        Found in src/HandlerContainer.php - About 30 mins to fix

          Missing class import via use statement (line '70', column '34').
          Open

                      $item->expiresAt(new \DateTime('now + ' . $expiry . 'seconds'));
          Severity: Minor
          Found in src/CacheWrapper.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 '34', column '28').
          Open

                  $parameters = (new \ReflectionClass($params->className))->getMethod($params->method)->getParameters();
          Severity: Minor
          Found in src/Middleware/ParameterMatcher.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 '29', column '23').
          Open

                      throw new \InvalidArgumentException('Expect PSR 6/16 compatible cache object');
          Severity: Minor
          Found in src/CacheWrapper.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

          Severity
          Category
          Status
          Source
          Language