psecio/gatekeeper

View on GitHub

Showing 44 of 44 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace Psecio\Gatekeeper;

class GroupCollection extends \Psecio\Gatekeeper\Collection\Mysql
Severity: Major
Found in src/Psecio/Gatekeeper/GroupCollection.php and 1 other location - About 1 day to fix
src/Psecio/Gatekeeper/UserCollection.php on lines 1..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 245.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace Psecio\Gatekeeper;

class UserCollection extends \Psecio\Gatekeeper\Collection\Mysql
Severity: Major
Found in src/Psecio/Gatekeeper/UserCollection.php and 1 other location - About 1 day to fix
src/Psecio/Gatekeeper/GroupCollection.php on lines 1..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 245.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected $properties = array(
        'name' => array(
            'description' => 'Group Name',
            'column' => 'name',
            'type' => 'varchar'
Severity: Major
Found in src/Psecio/Gatekeeper/PermissionModel.php and 1 other location - About 7 hrs to fix
src/Psecio/Gatekeeper/GroupModel.php on lines 17..75

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 244.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    protected $properties = array(
        'description' => array(
            'description' => 'Group Description',
            'column' => 'description',
            'type' => 'varchar'
Severity: Major
Found in src/Psecio/Gatekeeper/GroupModel.php and 1 other location - About 7 hrs to fix
src/Psecio/Gatekeeper/PermissionModel.php on lines 26..84

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 244.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File UserModel.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Psecio\Gatekeeper;

/**
Severity: Minor
Found in src/Psecio/Gatekeeper/UserModel.php - About 4 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function grantGroups(array $groups, $expire = null)
        {
            $return = true;
            foreach ($groups as $group) {
                $group = ($group instanceof GroupModel) ? $group->id : $group;
    Severity: Major
    Found in src/Psecio/Gatekeeper/UserModel.php and 1 other location - About 4 hrs to fix
    src/Psecio/Gatekeeper/UserModel.php on lines 476..495

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 179.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function grantPermissions(array $permissions, $expire = null)
        {
            $return = true;
            foreach ($permissions as $permission) {
                $permission = ($permission instanceof PermissionModel) ? $permission->id : $permission;
    Severity: Major
    Found in src/Psecio/Gatekeeper/UserModel.php and 1 other location - About 4 hrs to fix
    src/Psecio/Gatekeeper/UserModel.php on lines 504..523

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 179.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File Gatekeeper.php has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Psecio\Gatekeeper;
    
    use \Psecio\Gatekeeper\Model\User;
    Severity: Minor
    Found in src/Psecio/Gatekeeper/Gatekeeper.php - About 3 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      <?php
      
      namespace Psecio\Gatekeeper;
      
      class UserPermissionModel extends \Psecio\Gatekeeper\Model\Mysql
      Severity: Major
      Found in src/Psecio/Gatekeeper/UserPermissionModel.php and 1 other location - About 3 hrs to fix
      src/Psecio/Gatekeeper/UserGroupModel.php on lines 1..49

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 152.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      <?php
      
      namespace Psecio\Gatekeeper;
      
      class UserGroupModel extends \Psecio\Gatekeeper\Model\Mysql
      Severity: Major
      Found in src/Psecio/Gatekeeper/UserGroupModel.php and 1 other location - About 3 hrs to fix
      src/Psecio/Gatekeeper/UserPermissionModel.php on lines 1..49

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 152.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Gatekeeper has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Gatekeeper
      {
          /**
           * Database (PDO) instance
           * @var \PDO
      Severity: Minor
      Found in src/Psecio/Gatekeeper/Gatekeeper.php - About 3 hrs to fix

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        namespace Psecio\Gatekeeper;
        
        class GroupParentModel extends \Psecio\Gatekeeper\Model\Mysql
        Severity: Major
        Found in src/Psecio/Gatekeeper/GroupParentModel.php and 2 other locations - About 2 hrs to fix
        src/Psecio/Gatekeeper/GroupPermissionModel.php on lines 1..44
        src/Psecio/Gatekeeper/PermissionParentModel.php on lines 1..44

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 131.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        namespace Psecio\Gatekeeper;
        
        class PermissionParentModel extends \Psecio\Gatekeeper\Model\Mysql
        Severity: Major
        Found in src/Psecio/Gatekeeper/PermissionParentModel.php and 2 other locations - About 2 hrs to fix
        src/Psecio/Gatekeeper/GroupParentModel.php on lines 1..44
        src/Psecio/Gatekeeper/GroupPermissionModel.php on lines 1..44

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 131.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        namespace Psecio\Gatekeeper;
        
        class GroupPermissionModel extends \Psecio\Gatekeeper\Model\Mysql
        Severity: Major
        Found in src/Psecio/Gatekeeper/GroupPermissionModel.php and 2 other locations - About 2 hrs to fix
        src/Psecio/Gatekeeper/GroupParentModel.php on lines 1..44
        src/Psecio/Gatekeeper/PermissionParentModel.php on lines 1..44

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 131.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        class CreateUserPermissionTable extends \Psecio\Gatekeeper\PhinxMigration
        {
            protected $tableName = 'user_permission';
        Severity: Major
        Found in migrations/20141213161408_create_user_permission_table.php and 2 other locations - About 2 hrs to fix
        migrations/20141211205817_create_group_user_table.php on lines 1..28
        migrations/20141214082627_create_group_permission_table.php on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 129.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        class CreateGroupPermissionTable extends \Psecio\Gatekeeper\PhinxMigration
        {
            protected $tableName = 'group_permission';
        Severity: Major
        Found in migrations/20141214082627_create_group_permission_table.php and 2 other locations - About 2 hrs to fix
        migrations/20141211205817_create_group_user_table.php on lines 1..28
        migrations/20141213161408_create_user_permission_table.php on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 129.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        <?php
        
        class CreateGroupUserTable extends \Psecio\Gatekeeper\PhinxMigration
        {
            protected $tableName = 'user_group';
        Severity: Major
        Found in migrations/20141211205817_create_group_user_table.php and 2 other locations - About 2 hrs to fix
        migrations/20141213161408_create_user_permission_table.php on lines 1..28
        migrations/20141214082627_create_group_permission_table.php on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 129.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        class UserModel extends \Psecio\Gatekeeper\Model\Mysql
        {
            const STATUS_ACTIVE = 'active';
            const STATUS_INACTIVE = 'inactive';
        
        
        Severity: Minor
        Found in src/Psecio/Gatekeeper/UserModel.php - About 2 hrs to fix

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

              public static function authenticate(array $credentials, $remember = false)
              {
                  $username = $credentials['username'];
                  $user = new UserModel(self::$datasource);
                  $user->findByUsername($username);
          Severity: Minor
          Found in src/Psecio/Gatekeeper/Gatekeeper.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 find has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function find(\Modler\Model $model, array $where = array(), $multiple = false)
              {
                  $properties = $model->getProperties();
                  list($columns, $bind) = $this->setup($where);
                  $update = array();
          Severity: Minor
          Found in src/Psecio/Gatekeeper/DataSource/Mysql.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