CleverStack/angular-seed

View on GitHub
app/modules/roles/providers/RoleHelpersProvider.js

Summary

Maintainability
F
5 days
Test Coverage

Function $get has 223 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      $get: function( $injector, $rootScope, $timeout, $location ) {
        var Messenger           = $injector.has( 'Messenger' ) ? $injector.get( 'Messenger' ) : $injector.get( '$log' )
          , RoleService         = $injector.has( 'RoleService' ) ? $injector.get( 'RoleService' ) : false
          , PermissionService   = $injector.has( 'PermissionService' ) ? $injector.get( 'PermissionService' ) : false
          , UserService         = $injector.has( 'UserService' ) ? $injector.get( 'UserService' ) : false
Severity: Major
Found in app/modules/roles/providers/RoleHelpersProvider.js - About 1 day to fix

    Function openRoleModal has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            helpers.openRoleModal = function( role ) {
              ModalFactory.open( role, '/modules/roles/views/role/form.html', {
                controller: 'RoleEditController',
                resolve: {
                  role: function() {
    Severity: Minor
    Found in app/modules/roles/providers/RoleHelpersProvider.js - About 2 hrs to fix

      Function openDeletePermissionModal has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              helpers.openDeletePermissionModal = function( permission ) {
                ModalFactory.open( {}, '/modules/cs_modal/views/confirmModal.html', {
                  resolve: {
                    title: function() {
                      return 'Delete the "' + permission.action + '" Permission?';
      Severity: Minor
      Found in app/modules/roles/providers/RoleHelpersProvider.js - About 1 hr to fix

        Function openDeleteRoleModal has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                helpers.openDeleteRoleModal = function( role ) {
                  ModalFactory.open( {}, '/modules/cs_modal/views/confirmModal.html', {
                    resolve: {
                      title: function() {
                        return 'Delete the "' + role.name + '" Role?';
        Severity: Minor
        Found in app/modules/roles/providers/RoleHelpersProvider.js - About 1 hr to fix

          Function openPermissionModal has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  helpers.openPermissionModal = function( permission ) {
                    ModalFactory.open( permission, '/modules/roles/views/permission/form.html', {
                      controller: 'PermissionEditController',
                      resolve: {
                        permission: function() {
          Severity: Minor
          Found in app/modules/roles/providers/RoleHelpersProvider.js - About 1 hr to fix

            Function ensurePermission has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    helpers.ensurePermission = function( permission ) {
                      var hasPerm;
                      var scope = $rootScope.$new(true);
                      var clearWatcher = scope.$watch('user', function(user){
                        if(!user){
            Severity: Minor
            Found in app/modules/roles/providers/RoleHelpersProvider.js - About 1 hr to fix

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

                      helpers.openDeletePermissionModal = function( permission ) {
                        ModalFactory.open( {}, '/modules/cs_modal/views/confirmModal.html', {
                          resolve: {
                            title: function() {
                              return 'Delete the "' + permission.action + '" Permission?';
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 1 other location - About 1 day to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 76..117

              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 236.

              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

                      helpers.openDeleteRoleModal = function( role ) {
                        ModalFactory.open( {}, '/modules/cs_modal/views/confirmModal.html', {
                          resolve: {
                            title: function() {
                              return 'Delete the "' + role.name + '" Role?';
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 1 other location - About 1 day to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 160..201

              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 236.

              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

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

                              if ( typeof role === 'object' ) {
                                role.Users        = role.Users.map( function( user ) {
                                  return user.id;
                                });
                                role.Permissions  = role.Permissions.map( function( permission ) {
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 1 other location - About 2 hrs to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 35..45

              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 78.

              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

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

                                  .then( function( role ) {
              
                                    role.Users        = role.Users.map( function( user ) {
                                      return user.id;
                                    });
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 1 other location - About 2 hrs to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 23..32

              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 78.

              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

                            permissions: function() {
                              return PermissionService
                                .list()
                                .then( function( permissions ) {
                                  return permissions;
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 2 other locations - About 1 hr to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 51..60
              app/modules/roles/providers/RoleHelpersProvider.js on lines 146..155

              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 70.

              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

                            roles: function() {
                              return RoleService
                                .list()
                                .then( function( roles ) {
                                  return roles;
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 2 other locations - About 1 hr to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 51..60
              app/modules/roles/providers/RoleHelpersProvider.js on lines 62..71

              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 70.

              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

                            users: function() {
                              return UserService
                                .list()
                                .then( function( users ) {
                                  return users;
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 2 other locations - About 1 hr to fix
              app/modules/roles/providers/RoleHelpersProvider.js on lines 62..71
              app/modules/roles/providers/RoleHelpersProvider.js on lines 146..155

              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 70.

              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

                          if (user && user.role && user.Role.Permissions) {
                            user.Role.Permissions.every(function(perm) {
                              if (perm.action === permission) {
                                hasPerm = true;
                                return false;
              Severity: Major
              Found in app/modules/roles/providers/RoleHelpersProvider.js and 1 other location - About 1 hr to fix
              app/modules/auth/providers/SessionProvider.js on lines 356..364

              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 57.

              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

              There are no issues that match your filters.

              Category
              Status