CleverStack/angular-seed

View on GitHub
app/modules/auth/providers/SessionProvider.js

Summary

Maintainability
D
2 days
Test Coverage

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

        function( $rootScope, $location, $route, $injector, $log ) {
          var messenger = $injector.has( 'Messenger' ) ? $injector.get( 'Messenger' ) : $log;

          if ( !sessionService && sessionServiceName ) {
            sessionService = $injector.get( sessionServiceName );
Severity: Major
Found in app/modules/auth/providers/SessionProvider.js - About 1 day to fix

    File SessionProvider.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    define( [ 'angular', '../module' ], function( ng ) {
      'use strict';
    
      /**
       * @ngdoc service
    Severity: Minor
    Found in app/modules/auth/providers/SessionProvider.js - About 4 hrs to fix

      Function locationChange has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                handlers.locationChange = handlers.locationChange || function( event, next ) {
                  next = '/' + next.split( '/' ).splice( 3 ).join( '/' ).split( '?' )[ 0 ];
                  if( next.length > 1 && next.substr(-1) === '/' ){
                    next = next.substr(0, next.length - 1);
                  }
      Severity: Major
      Found in app/modules/auth/providers/SessionProvider.js - About 2 hrs to fix

        Function switchRouteMatcher has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function switchRouteMatcher(on, when, whenProperties) {
                // TODO(i): this code is convoluted and inefficient, we should construct the route matching
                //   regex only once and then reuse it
        
                // Escape regexp special characters.
        Severity: Minor
        Found in app/modules/auth/providers/SessionProvider.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                        if ( route && ( !route.public || route.requiresPermission || route.requiresPermissions || route.permissions || route.roles ) ) {
                          $rootScope.$broadcast( 'SessionProvider:signInStart' );
                          handlers.signInStart( next.substr( 1 ) );
                        }
          Severity: Major
          Found in app/modules/auth/providers/SessionProvider.js - About 40 mins to fix

            Function $get has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    function( $rootScope, $location, $route, $injector, $log ) {
            Severity: Minor
            Found in app/modules/auth/providers/SessionProvider.js - About 35 mins to fix

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

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

              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

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

                        $rootScope.$on( 'SessionProvider:signOutSuccess', function() {
                          if ( ng.isFunction( handlers.signOutSuccess ) ) {
                            handlers.signOutSuccess();
                          }
                        });
              Severity: Minor
              Found in app/modules/auth/providers/SessionProvider.js and 1 other location - About 35 mins to fix
              app/modules/auth/providers/SessionProvider.js on lines 433..437

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

              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

                        $rootScope.$on( 'SessionProvider:signInSuccess', function() {
                          if ( ng.isFunction( handlers.signInSuccess ) ) {
                            handlers.signInSuccess();
                          }
                        });
              Severity: Minor
              Found in app/modules/auth/providers/SessionProvider.js and 1 other location - About 35 mins to fix
              app/modules/auth/providers/SessionProvider.js on lines 439..443

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

              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