laravel/framework

View on GitHub
src/Illuminate/Auth/Access/Gate.php

Summary

Maintainability
D
1 day
Test Coverage

File Gate.php has 407 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Auth\Access;

use Closure;
Severity: Minor
Found in src/Illuminate/Auth/Access/Gate.php - About 5 hrs to fix

    Gate has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Gate implements GateContract
    {
        use HandlesAuthorization;
    
        /**
    Severity: Minor
    Found in src/Illuminate/Auth/Access/Gate.php - About 5 hrs to fix

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

          public function getPolicyFor($class)
          {
              if (is_object($class)) {
                  $class = get_class($class);
              }
      Severity: Minor
      Found in src/Illuminate/Auth/Access/Gate.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

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

          public function __construct(Container $container,
              callable $userResolver,
              array $abilities = [],
              array $policies = [],
              array $beforeCallbacks = [],
      Severity: Major
      Found in src/Illuminate/Auth/Access/Gate.php - About 50 mins to fix

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

            protected function callBeforeCallbacks($user, $ability, array $arguments)
            {
                foreach ($this->beforeCallbacks as $before) {
                    if (! $this->canBeCalledWithUser($user, $before)) {
                        continue;
        Severity: Minor
        Found in src/Illuminate/Auth/Access/Gate.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

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

            protected function resolveAuthCallback($user, $ability, array $arguments)
            {
                if (isset($arguments[0]) &&
                    ! is_null($policy = $this->getPolicyFor($arguments[0])) &&
                    $callback = $this->resolvePolicyCallback($user, $ability, $arguments, $policy)) {
        Severity: Minor
        Found in src/Illuminate/Auth/Access/Gate.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

        There are no issues that match your filters.

        Category
        Status