artesaos/defender

View on GitHub

Showing 15 of 21 total issues

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

    public function handle($request, Closure $next, $roles = null, $any = false)
    {
        if (is_null($roles)) {
            $roles = $this->getRoles($request);
            $anyRole = $this->getAny($request);
Severity: Minor
Found in src/Defender/Middlewares/NeedsRoleMiddleware.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 handle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle($request, Closure $next, $permissions = null, $any = false)
    {
        if (is_null($permissions)) {
            $permissions = $this->getPermissions($request);
            $anyPermission = $this->getAny($request);
Severity: Minor
Found in src/Defender/Middlewares/NeedsPermissionMiddleware.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 handle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle($request, Closure $next, $permissions = null, $any = false)
    {
        if (is_null($permissions)) {
            $permissions = $this->getPermissions($request);
            $anyPermission = $this->getAny($request);
Severity: Minor
Found in src/Defender/Middlewares/NeedsPermissionMiddleware.php - About 1 hr to fix

    Method handle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handle($request, Closure $next, $roles = null, $any = false)
        {
            if (is_null($roles)) {
                $roles = $this->getRoles($request);
                $anyRole = $this->getAny($request);
    Severity: Minor
    Found in src/Defender/Middlewares/NeedsRoleMiddleware.php - About 1 hr to fix

      Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
      Severity: Minor
      Found in src/Defender/Traits/Users/HasPermissions.php - About 35 mins to fix

        Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
        Severity: Minor
        Found in src/Defender/Traits/Models/Permission.php - About 35 mins to fix

          Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
          Severity: Minor
          Found in src/Defender/Traits/Permissions/RoleHasPermissions.php - About 35 mins to fix

            Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null);
            Severity: Minor
            Found in src/Defender/Contracts/Permission.php - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                              return '<?php endif; ?>';
              Severity: Major
              Found in src/Defender/Providers/DefenderServiceProvider.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return new EloquentPermissionRepository($app, $app->make(\Artesaos\Defender\Contracts\Permission::class));
                Severity: Major
                Found in src/Defender/Providers/DefenderServiceProvider.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $next($request);
                  Severity: Major
                  Found in src/Defender/Middlewares/NeedsPermissionMiddleware.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return new EloquentUserRepository($app, $app->make($userModel));
                    Severity: Major
                    Found in src/Defender/Providers/DefenderServiceProvider.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $next($request);
                      Severity: Major
                      Found in src/Defender/Middlewares/NeedsRoleMiddleware.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return $app['defender.permission'];
                        Severity: Major
                        Found in src/Defender/Providers/DefenderServiceProvider.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $app['defender.user'];
                          Severity: Major
                          Found in src/Defender/Providers/DefenderServiceProvider.php - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language