laravel/framework

View on GitHub
src/Illuminate/Foundation/Console/RouteListCommand.php

Summary

Maintainability
C
1 day
Test Coverage

File RouteListCommand.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Foundation\Console;

use Closure;
Severity: Minor
Found in src/Illuminate/Foundation/Console/RouteListCommand.php - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (($this->option('name') && ! Str::contains((string) $route['name'], $this->option('name'))) ||
                ($this->option('path') && ! Str::contains($route['uri'], $this->option('path'))) ||
                ($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) ||
                ($this->option('domain') && ! Str::contains((string) $route['domain'], $this->option('domain'))) ||
                ($this->option('except-vendor') && $route['vendor']) ||
    Severity: Critical
    Found in src/Illuminate/Foundation/Console/RouteListCommand.php - About 2 hrs to fix

      Function filterRoute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function filterRoute(array $route)
          {
              if (($this->option('name') && ! Str::contains((string) $route['name'], $this->option('name'))) ||
                  ($this->option('path') && ! Str::contains($route['uri'], $this->option('path'))) ||
                  ($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) ||
      Severity: Minor
      Found in src/Illuminate/Foundation/Console/RouteListCommand.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

      RouteListCommand has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      #[AsCommand(name: 'route:list')]
      class RouteListCommand extends Command
      {
          /**
           * The console command name.
      Severity: Minor
      Found in src/Illuminate/Foundation/Console/RouteListCommand.php - About 2 hrs to fix

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

            protected function forCli($routes)
            {
                $routes = $routes->map(
                    fn ($route) => array_merge($route, [
                        'action' => $this->formatActionForCli($route),
        Severity: Minor
        Found in src/Illuminate/Foundation/Console/RouteListCommand.php - About 1 hr to fix

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

              protected function isVendorRoute(Route $route)
              {
                  if ($route->action['uses'] instanceof Closure) {
                      $path = (new ReflectionFunction($route->action['uses']))
                                          ->getFileName();
          Severity: Minor
          Found in src/Illuminate/Foundation/Console/RouteListCommand.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

          There are no issues that match your filters.

          Category
          Status