divineniiquaye/flight-routing

View on GitHub

Showing 55 of 59 total issues

Function resolveParameters has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    protected function resolveParameters(array $refParameters, array $arguments): array
    {
        $parameters = [];
        $nullable = 0;

Severity: Minor
Found in src/Handlers/RouteInvoker.php - About 6 hrs 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

File PrototypeTrait.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

/*
 * This file is part of Flight Routing.
 *
Severity: Minor
Found in src/Traits/PrototypeTrait.php - About 3 hrs to fix

    Function load has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public function load(array $annotations): RouteCollection
        {
            foreach ($annotations as $annotation) {
                $reflection = $annotation['type'];
                $attributes = $annotation['attributes'] ?? [];
    Severity: Minor
    Found in src/Annotation/Listener.php - About 3 hrs 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 buildCache has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function buildCache(RouteCollection $collection, bool $doCache): string
        {
            $dynamicRoutes = $dynamicVar = $staticRoutes = [];
            $dynamicString = ":static function (string \$path): ?array {\n      ";
    
    
    Severity: Minor
    Found in src/Traits/CacheTrait.php - About 3 hrs 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 addRoute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function addRoute(RouteCollection $collection, Route $route, mixed $handler): RouteCollection
        {
            if (true !== $handler) {
                if (empty($route->path)) {
                    throw new InvalidAnnotationException('Attributed method route path empty');
    Severity: Minor
    Found in src/Annotation/Listener.php - About 2 hrs 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

    RouteCollection has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class RouteCollection implements \Countable, \ArrayAccess
    {
        use Traits\PrototypeTrait;
    
        /**
    Severity: Minor
    Found in src/RouteCollection.php - About 2 hrs to fix

      Function interpolate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function interpolate(string $uriRoute, array $uriVars, array $parameters): string
          {
              $required = []; // Parameters required which are missing.
              $replaces = self::URI_FIXERS;
      
      
      Severity: Minor
      Found in src/RouteCompiler.php - About 2 hrs 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

      Method resolveParameters has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function resolveParameters(array $refParameters, array $arguments): array
          {
              $parameters = [];
              $nullable = 0;
      
      
      Severity: Minor
      Found in src/Handlers/RouteInvoker.php - About 1 hr to fix

        Function __invoke has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __invoke(mixed $handler, array $arguments): mixed
            {
                if (\is_string($handler)) {
                    $handler = \ltrim($handler, '\\');
        
        
        Severity: Minor
        Found in src/Handlers/RouteInvoker.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

        Function domain has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function domain(string ...$domains): self
            {
                $resolver = static function (array &$route, array $domains): void {
                    foreach ($domains as $domain) {
                        if (1 === \preg_match('/^(?:([a-z]+)\:\/{2})?([^\/]+)?$/u', $domain, $m, \PREG_UNMATCHED_AS_NULL)) {
        Severity: Minor
        Found in src/Traits/PrototypeTrait.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

        Method export has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function export(mixed $value, string $indent = ''): string
            {
                switch (true) {
                    case [] === $value:
                        return '[]';
        Severity: Minor
        Found in src/Traits/CacheTrait.php - About 1 hr to fix

          Method buildCache has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function buildCache(RouteCollection $collection, bool $doCache): string
              {
                  $dynamicRoutes = $dynamicVar = $staticRoutes = [];
                  $dynamicString = ":static function (string \$path): ?array {\n      ";
          
          
          Severity: Minor
          Found in src/Traits/CacheTrait.php - About 1 hr to fix

            Function injectGroups has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                private function injectGroups(string $prefix, array &$collection, int &$count): void
                {
                    $unnamedRoutes = [];
            
                    foreach ($this->groups as $group) {
            Severity: Minor
            Found in src/RouteCollection.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

            Method addRoute has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addRoute(RouteCollection $collection, Route $route, mixed $handler): RouteCollection
                {
                    if (true !== $handler) {
                        if (empty($route->path)) {
                            throw new InvalidAnnotationException('Attributed method route path empty');
            Severity: Minor
            Found in src/Annotation/Listener.php - About 1 hr to fix

              Method interpolate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function interpolate(string $uriRoute, array $uriVars, array $parameters): string
                  {
                      $required = []; // Parameters required which are missing.
                      $replaces = self::URI_FIXERS;
              
              
              Severity: Minor
              Found in src/RouteCompiler.php - About 1 hr to fix

                Function resolveHandler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function resolveHandler(mixed $handler, string $namespace = null): mixed
                    {
                        if (empty($namespace)) {
                            return $handler;
                        }
                Severity: Minor
                Found in src/Traits/PrototypeTrait.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

                Function compile has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function compile(string $route, array $placeholders = [], bool $reversed = false): array
                    {
                        $variables = $replaces = [];
                
                        if (\strpbrk($route, '{')) {
                Severity: Minor
                Found in src/RouteCompiler.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

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

                    public static function resolveRoute(
                        ServerRequestInterface $request,
                        callable $resolver,
                        mixed $handler,
                        callable $arguments,
                Severity: Minor
                Found in src/Handlers/RouteInvoker.php - About 1 hr to fix

                  Function resolveRoute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function resolveRoute(
                          ServerRequestInterface $request,
                          callable $resolver,
                          mixed $handler,
                          callable $arguments,
                  Severity: Minor
                  Found in src/Handlers/RouteInvoker.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

                  Function resolveRoute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function resolveRoute(string $path, string $method, UriInterface $uri): ?array
                      {
                          $errors = [[], []];
                  
                          foreach ($this->getCollection()->getRoutes() as $i => $r) {
                  Severity: Minor
                  Found in src/Traits/ResolverTrait.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

                  Severity
                  Category
                  Status
                  Source
                  Language