mateusjunges/laravel-acl

View on GitHub

Showing 16 of 25 total issues

File HasPermissions.php has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Junges\ACL\Concerns;

use Illuminate\Database\Eloquent\Builder;
Severity: Minor
Found in src/Concerns/HasPermissions.php - About 2 hrs to fix

    Method up has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function up()
        {
            $teams = config('acl.teams');
            $tableNames = config('acl.tables');
            $columnNames = config('acl.column_names');
    Severity: Major
    Found in database/migrations/add_teams_fields.php - About 2 hrs to fix

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

      class AclRegistrar
      {
          protected Repository $cache;
          protected CacheManager $cacheManager;
          protected string $permissionClass;
      Severity: Minor
      Found in src/AclRegistrar.php - About 2 hrs to fix

        Function up has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function up()
            {
                $teams = config('acl.teams');
                $tableNames = config('acl.tables');
                $columnNames = config('acl.column_names');
        Severity: Minor
        Found in database/migrations/add_teams_fields.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 assignGroup has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function assignGroup($groups): self
            {
                $groups = collect(is_array($groups) || $groups instanceof Collection ? $groups : func_get_args())
                    ->flatten()
                    ->reduce(function ($array, $group) {
        Severity: Minor
        Found in src/Concerns/HasGroups.php - About 1 hr to fix

          Method assignPermission has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function assignPermission($permissions): self
              {
                  $permissions = collect(is_array($permissions) || $permissions instanceof Collection ? $permissions : func_get_args())
                      ->flatten()
                      ->reduce(function ($array, $permission) {
          Severity: Minor
          Found in src/Concerns/HasPermissions.php - About 1 hr to fix

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

                public function hasGroup($groups, string $guard = null): bool
                {
                    if (is_string($groups) && strpos($groups, '|') !== false) {
                        $groups = $this->convertPipeToArray($groups);
                    }
            Severity: Minor
            Found in src/Concerns/HasGroups.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 hasGroup has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function hasGroup($groups, string $guard = null): bool
                {
                    if (is_string($groups) && strpos($groups, '|') !== false) {
                        $groups = $this->convertPipeToArray($groups);
                    }
            Severity: Minor
            Found in src/Concerns/HasGroups.php - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

                        return $permissions;
                Severity: Major
                Found in src/Concerns/HasPermissions.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $this;
                  Severity: Major
                  Found in src/Concerns/HasPermissions.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return "<?php }else if(auth({$guard})->check() && auth({$guard})->user()->hasPermission({$permission})){?>";
                    Severity: Major
                    Found in src/Providers/ACLViewServiceProvider.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $this;
                      Severity: Major
                      Found in src/Concerns/HasGroups.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return false;
                        Severity: Major
                        Found in src/Concerns/HasGroups.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return $this->groups->intersect($guard ? $groups->where('guard_name', $guard) : $groups)->isNotEmpty();
                          Severity: Major
                          Found in src/Concerns/HasGroups.php - About 30 mins to fix

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

                                public static function getNames($model): Collection
                                {
                                    $class = is_object($model) ? get_class($model) : $model;
                            
                                    if (is_object($model)) {
                            Severity: Minor
                            Found in src/Guard.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

                            Severity
                            Category
                            Status
                            Source
                            Language