hueitan/angular-validation

View on GitHub

Showing 21 of 21 total issues

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

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 Provider has 156 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function Provider() {
        var $injector;
        var $scope;
        var $http;
        var $q;
    Severity: Major
    Found in src/provider.js - About 6 hrs 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

        Function exports has 101 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(grunt) {
          require('time-grunt')(grunt);
        
          // Grunt Config
          grunt.initConfig({
        Severity: Major
        Found in Gruntfile.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 validate has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  this.validate = function(form) {
                    var deferred = $q.defer();
                    var idx = 0;
              
                    if (form === undefined) {
              Severity: Minor
              Found in src/provider.js - About 1 hr 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

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

                        this.setErrorHTML = function(func) {
                          if (func.constructor !== Function) {
                            return;
                          }
                          _this.getErrorHTML = func;
                    Severity: Minor
                    Found in src/provider.js and 1 other location - About 50 mins to fix
                    src/provider.js on lines 126..132

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

                    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

                        this.setSuccessHTML = function(func) {
                          if (func.constructor !== Function) {
                            return;
                          }
                          _this.getSuccessHTML = func;
                    Severity: Minor
                    Found in src/provider.js and 1 other location - About 50 mins to fix
                    src/provider.js on lines 104..110

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

                    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

                    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

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

                                  minlength: function(value, scope, element, attrs, param) {
                          Severity: Minor
                          Found in src/rule.js - About 35 mins to fix

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

                                    maxlength: function(value, scope, element, attrs, param) {
                            Severity: Minor
                            Found in src/rule.js - About 35 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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language