netceteragroup/valdr

View on GitHub

Showing 72 of 72 total issues

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

describe('valdrUrlValidator', function () {

  var urlValidator;

  beforeEach(module('valdr'));
Severity: Major
Found in src/core/validators/urlValidator.spec.js and 1 other location - About 2 days to fix
src/core/validators/hibernateUrlValidator.spec.js on lines 1..37

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

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

describe('valdrHibernateUrlValidator', function () {

  var urlValidator;

  beforeEach(module('valdr'));
Severity: Major
Found in src/core/validators/hibernateUrlValidator.spec.js and 1 other location - About 2 days to fix
src/core/validators/urlValidator.spec.js on lines 1..37

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

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

  it('should return true for dates in the past', function () {
    expect(pastValidator.validate('1.1.1900')).toBe(true);
    expect(pastValidator.validate('01.01.1900')).toBe(true);
    expect(pastValidator.validate('1. 1. 1900')).toBe(true);
    expect(pastValidator.validate('01. 01. 1900')).toBe(true);
Severity: Major
Found in src/core/validators/pastValidator.spec.js and 1 other location - About 1 day to fix
src/core/validators/futureValidator.spec.js on lines 33..47

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

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

  it('should return false for dates in the past', function () {
    expect(futureValidator.validate('1.1.1900')).toBe(false);
    expect(futureValidator.validate('01.01.1900')).toBe(false);
    expect(futureValidator.validate('1. 1. 1900')).toBe(false);
    expect(futureValidator.validate('01. 01. 1900')).toBe(false);
Severity: Major
Found in src/core/validators/futureValidator.spec.js and 1 other location - About 1 day to fix
src/core/validators/pastValidator.spec.js on lines 40..54

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

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

module.exports = function (grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
Severity: Major
Found in Gruntfile.js - About 5 hrs to fix

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

      it('should return false for non-dates', function () {
        expect(pastValidator.validate(' ')).toBe(false);
        expect(pastValidator.validate('foo')).toBe(false);
        expect(pastValidator.validate('_1.1.2014')).toBe(false);
        expect(pastValidator.validate('31.2.2014')).toBe(false);
    Severity: Major
    Found in src/core/validators/pastValidator.spec.js and 1 other location - About 4 hrs to fix
    src/core/validators/futureValidator.spec.js on lines 25..31

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

    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

      it('should return false for non-dates', function () {
        expect(futureValidator.validate(' ')).toBe(false);
        expect(futureValidator.validate('foo')).toBe(false);
        expect(futureValidator.validate('_1.1.2014')).toBe(false);
        expect(futureValidator.validate('31.2.2014')).toBe(false);
    Severity: Major
    Found in src/core/validators/futureValidator.spec.js and 1 other location - About 4 hrs to fix
    src/core/validators/pastValidator.spec.js on lines 25..31

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

    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

      it('should update field names on language switch at runtime', function () {
        // given
        valdrMessage.setTemplate('<div>{{ violations[0].fieldName }}</div>');
        var element = compileTemplate();
        expect(element.find('div').html()).toBe('The Field Name');
    Severity: Major
    Found in src/message/valdrMessage-directive.spec.js and 1 other location - About 4 hrs to fix
    src/message/valdrMessage-directive.spec.js on lines 317..329

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

    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

      it('should update field names on language switch at runtime', function () {
        // given
        valdrMessage.setTemplate('<div>{{ violations[0].fieldName }}</div>');
        var element = compileTemplate();
        expect(element.find('div').html()).toBe('Field Name');
    Severity: Major
    Found in src/message/valdrMessage-directive.spec.js and 1 other location - About 4 hrs to fix
    src/message/valdrMessage-directive.spec.js on lines 442..454

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

    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

      it('should return false for dates in the future', function () {
        expect(pastValidator.validate('1.1.2900')).toBe(false);
        expect(pastValidator.validate('2030/12/31')).toBe(false);
        expect(pastValidator.validate('2030-12-31')).toBe(false);
        expect(pastValidator.validate(moment().add(10, 'seconds'))).toBe(false);
    Severity: Major
    Found in src/core/validators/pastValidator.spec.js and 1 other location - About 4 hrs to fix
    src/core/validators/futureValidator.spec.js on lines 49..54

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

    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

      it('should return true for dates in the future', function () {
        expect(futureValidator.validate('1.1.2900')).toBe(true);
        expect(futureValidator.validate('2030/12/31')).toBe(true);
        expect(futureValidator.validate('2030-12-31')).toBe(true);
        expect(futureValidator.validate(moment().add(10, 'seconds'))).toBe(true);
    Severity: Major
    Found in src/core/validators/futureValidator.spec.js and 1 other location - About 4 hrs to fix
    src/core/validators/pastValidator.spec.js on lines 33..38

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

    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

    angular.module('valdr')
    
      .factory('valdrMaxValidator', ['valdrUtil', function (valdrUtil) {
    
        return {
    Severity: Major
    Found in src/core/validators/maxValidator.js and 1 other location - About 3 hrs to fix
    src/core/validators/minValidator.js on lines 1..27

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

    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

    angular.module('valdr')
    
      .factory('valdrMinValidator', ['valdrUtil', function (valdrUtil) {
    
        return {
    Severity: Major
    Found in src/core/validators/minValidator.js and 1 other location - About 3 hrs to fix
    src/core/validators/maxValidator.js on lines 1..26

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

    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

    angular.module('valdr')
    
      .factory('valdrMaxLengthValidator', ['valdrUtil', function (valdrUtil) {
        return {
          name: 'maxLength',
    Severity: Major
    Found in src/core/validators/maxLengthValidator.js and 1 other location - About 3 hrs to fix
    src/core/validators/minLengthValidator.js on lines 1..28

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

    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

    angular.module('valdr')
    
      .factory('valdrMinLengthValidator', ['valdrUtil', function (valdrUtil) {
        return {
          name: 'minLength',
    Severity: Major
    Found in src/core/validators/minLengthValidator.js and 1 other location - About 3 hrs to fix
    src/core/validators/maxLengthValidator.js on lines 1..28

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

    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

    File valdrMessage-directive.spec.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    describe('valdrMessage input directive', function () {
    
      var $scope, $compile;
    
      beforeEach(module('valdr'));
    Severity: Minor
    Found in src/message/valdrMessage-directive.spec.js - About 3 hrs to fix

      Function valdrFormItemDirectiveDefinitionFactory has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      var valdrFormItemDirectiveDefinitionFactory = function (restrict) {
          return ['valdrEvents', 'valdr', 'valdrUtil', function (valdrEvents, valdr, valdrUtil) {
            return {
              restrict: restrict,
              require: ['?^valdrType', '?^ngModel', '?^valdrFormGroup', '?^valdrEnabled'],
      Severity: Minor
      Found in src/core/valdrFormItem-directive.js - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

              function ($log, $injector, $rootScope, $http, valdrEvents, valdrUtil, valdrClasses) {
      
                // inject all validators
                angular.forEach(validatorNames, function (validatorName) {
                  var validator = $injector.get(validatorName);
      Severity: Major
      Found in src/core/valdr-service.js - About 3 hrs to fix

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

          ['valdrClasses', 'valdrConfig', function (valdrClasses, valdrConfig) {
            return  {
              restrict: 'EA',
              link: function (scope, element) {
                if (valdrConfig.addFormGroupClass) {
        Severity: Major
        Found in src/core/valdrFormGroup-directive.js - About 2 hrs to fix

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

            it('should NOT add valdr-message after the input if valdr-no-validate is set', function () {
              // given
              var element = compileTemplate(
                  '<form name="demoForm">' +
                    '<div valdr-type="TestClass" valdr-form-group>' +
          Severity: Major
          Found in src/message/valdrMessage-directive.spec.js and 2 other locations - About 2 hrs to fix
          src/message/valdrMessage-directive.spec.js on lines 61..76
          src/message/valdrMessage-directive.spec.js on lines 78..93

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

          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

          Severity
          Category
          Status
          Source
          Language