gadael/gadael

View on GitHub
public/js/controllers/admin/user-view.js

Summary

Maintainability
C
7 hrs
Test Coverage

Consider simplifying this complex logical expression.
Open

        if ($scope.user.$promise) {
            $scope.user.$promise.then(function() {

                $scope.user.isAccount     = ($scope.user.roles && $scope.user.roles.account     !== undefined && $scope.user.roles.account     !== null);
                $scope.user.isAdmin     = ($scope.user.roles && $scope.user.roles.admin     !== undefined && $scope.user.roles.admin     !== null);
Severity: Major
Found in public/js/controllers/admin/user-view.js - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                                        if (adjustedRenewals[id].adjustmentSum !== 0) {
                                            $scope.adjustedRenewals.push(adjustedRenewals[id]);
                                        }
    Severity: Major
    Found in public/js/controllers/admin/user-view.js - About 45 mins to fix

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

                      $scope.user.isAdmin     = ($scope.user.roles && $scope.user.roles.admin     !== undefined && $scope.user.roles.admin     !== null);
      Severity: Major
      Found in public/js/controllers/admin/user-view.js and 4 other locations - About 1 hr to fix
      public/js/controllers/admin/user-edit.js on lines 24..24
      public/js/controllers/admin/user-edit.js on lines 25..25
      public/js/controllers/admin/user-edit.js on lines 26..26
      public/js/controllers/admin/user-view.js on lines 32..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 63.

      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 5 locations. Consider refactoring.
      Open

                      $scope.user.isAccount     = ($scope.user.roles && $scope.user.roles.account     !== undefined && $scope.user.roles.account     !== null);
      Severity: Major
      Found in public/js/controllers/admin/user-view.js and 4 other locations - About 1 hr to fix
      public/js/controllers/admin/user-edit.js on lines 24..24
      public/js/controllers/admin/user-edit.js on lines 25..25
      public/js/controllers/admin/user-edit.js on lines 26..26
      public/js/controllers/admin/user-view.js on lines 33..33

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

      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

              $scope.delete = function() {
                  if (confirm(gettext('Are you sure you want to delete this user?'))) {
                      $scope.user.gadaDelete($location.path('/admin/users'));
                  }
              };
      Severity: Minor
      Found in public/js/controllers/admin/user-view.js and 1 other location - About 55 mins to fix
      public/js/controllers/admin/compulsoryleave-view.js on lines 337..341

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

      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 (undefined !== $scope.user.roles && $scope.user.roles.account && $scope.user.roles.account._id) {
      
                          var account = $scope.user.roles.account;
      
                          $scope.accountScheduleCalendars = accountScheduleCalendars.query({ account: account._id });
      Severity: Minor
      Found in public/js/controllers/admin/user-view.js and 1 other location - About 45 mins to fix
      public/js/controllers/admin/account-renewalquantity-edit.js on lines 241..251

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

      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 (undefined !== account.seniority) {
                              var seniority = new Date(account.seniority);
                              $scope.seniority_years = today.getFullYear() - seniority.getFullYear();
                          }
      Severity: Minor
      Found in public/js/controllers/admin/user-view.js and 1 other location - About 40 mins to fix
      public/js/controllers/admin/user-view.js on lines 55..58

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

      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 (undefined !== account.birth) {
                              var birth = new Date(account.birth);
                              $scope.age = today.getFullYear() - birth.getFullYear();
                          }
      Severity: Minor
      Found in public/js/controllers/admin/user-view.js and 1 other location - About 40 mins to fix
      public/js/controllers/admin/user-view.js on lines 50..53

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

      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