hueitan/angular-validation

View on GitHub
src/validator.directive.js

Summary

Maintainability
F
1 wk
Test Coverage

Function Validator has 278 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function Validator($injector) {
    var $validationProvider = $injector.get('$validation');
    var $q = $injector.get('$q');
    var $timeout = $injector.get('$timeout');
    var $compile = $injector.get('$compile');
Severity: Major
Found in src/validator.directive.js - About 1 day to fix

    Function link has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          link: function(scope, element, attrs, ctrl) {
            /**
             * All attributes
             */
            var useViewValue = attrs.useViewValue !== 'false';
    Severity: Major
    Found in src/validator.directive.js - About 4 hrs to fix

      File validator.directive.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      (function() {
        angular
          .module('validation.directive')
          .directive('validator', Validator);
      
      
      Severity: Minor
      Found in src/validator.directive.js - About 2 hrs to fix

        Function checkValidation has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var checkValidation = function(scope, element, attrs, ctrl, validation, value) {
              var validators = validation.slice(0);
              var validatorExpr = validators[0].trim();
              var paramIndex = validatorExpr.indexOf('=');
              var validator = paramIndex === -1 ? validatorExpr : validatorExpr.substr(0, paramIndex);
        Severity: Major
        Found in src/validator.directive.js - About 2 hrs to fix

          Function invalidFunc has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              var invalidFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
          Severity: Major
          Found in src/validator.directive.js - About 50 mins to fix

            Function validFunc has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                var validFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
            Severity: Major
            Found in src/validator.directive.js - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        } else if (validationGroup) {
                          groups[validationGroup][ctrl.$name] = false;
              
                          // Whenever the element is invalid, we'll check whether one of the elements inside the its group valid or not.
                          // If there is a valid element, its invalid message won't be shown, Otherwise, shows its invalid message.
              Severity: Major
              Found in src/validator.directive.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (validationGroup) {
                              groups[validationGroup][ctrl.$name] = true;
                              setValidationGroup(scope, validationGroup, true);
                            }
                Severity: Major
                Found in src/validator.directive.js - About 45 mins to fix

                  Function checkValidation has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      var checkValidation = function(scope, element, attrs, ctrl, validation, value) {
                  Severity: Minor
                  Found in src/validator.directive.js - About 45 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              } else return valid.error();
                    Severity: Major
                    Found in src/validator.directive.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            } else return valid.error();
                      Severity: Major
                      Found in src/validator.directive.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                      return valid.error();
                        Severity: Major
                        Found in src/validator.directive.js - About 30 mins to fix

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

                              var validFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
                                var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).success;
                                var validCallback = $parse(attrs.validCallback);
                                var messageId = attrs.messageId;
                                var validationGroup = attrs.validationGroup;
                          Severity: Major
                          Found in src/validator.directive.js and 1 other location - About 1 day to fix
                          src/validator.directive.js on lines 63..91

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

                          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

                              var invalidFunc = function(element, validMessage, validation, scope, ctrl, attrs, param) {
                                var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).error;
                                var invalidCallback = $parse(attrs.invalidCallback);
                                var messageId = attrs.messageId;
                                var validationGroup = attrs.validationGroup;
                          Severity: Major
                          Found in src/validator.directive.js and 1 other location - About 1 day to fix
                          src/validator.directive.js on lines 23..51

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

                          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