unageanu/jiji2

View on GitHub
sites/src/js/utils/validation/validation-functions.js

Summary

Maintainability
D
2 days
Test Coverage

ValidationFunctions has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class ValidationFunctions {

  static notNull( value, restriction ) {
    if ( value === null || value === undefined || value === "" ) {
      return {type : "NOT_NULL"};
Severity: Minor
Found in sites/src/js/utils/validation/validation-functions.js - About 2 hrs to fix

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

      static noExternalCharacters( value ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        const m = value.match(EXTERNAL_CHARACTERS_REGEXP);
        if ( m ) {
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 2 hrs to fix
    sites/src/js/utils/validation/validation-functions.js on lines 124..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 76.

    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

      static noSpecials( value ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        const m = value.match(SPECIAL_CHARACTERS_REGEXP);
        if ( m ) {
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 2 hrs to fix
    sites/src/js/utils/validation/validation-functions.js on lines 133..141

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

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

      static alphabet( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !ALPHABET_REGEXP.test(value) ) {
            return {type : "NOT_ALPHABET"};
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 76..83
    sites/src/js/utils/validation/validation-functions.js on lines 84..91
    sites/src/js/utils/validation/validation-functions.js on lines 92..99
    sites/src/js/utils/validation/validation-functions.js on lines 108..115
    sites/src/js/utils/validation/validation-functions.js on lines 116..123

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

      static katakana( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !KATAKANA_REGEXP.test(value) ) {
            return {type : "NOT_KATAKANA"};
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 76..83
    sites/src/js/utils/validation/validation-functions.js on lines 84..91
    sites/src/js/utils/validation/validation-functions.js on lines 92..99
    sites/src/js/utils/validation/validation-functions.js on lines 100..107
    sites/src/js/utils/validation/validation-functions.js on lines 116..123

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

      static controlCode( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !CONTROL_CODE_REGEXP.test(value) ) {
            return { type : "CONTROL_CODE" };
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 84..91
    sites/src/js/utils/validation/validation-functions.js on lines 92..99
    sites/src/js/utils/validation/validation-functions.js on lines 100..107
    sites/src/js/utils/validation/validation-functions.js on lines 108..115
    sites/src/js/utils/validation/validation-functions.js on lines 116..123

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

      static numberOrHyphen( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !NUMBER_OR_HYPHEN_REGEXP.test(value) ) {
            return {type : "NOT_NUMBER_OR_HYPHEN"};
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 76..83
    sites/src/js/utils/validation/validation-functions.js on lines 84..91
    sites/src/js/utils/validation/validation-functions.js on lines 100..107
    sites/src/js/utils/validation/validation-functions.js on lines 108..115
    sites/src/js/utils/validation/validation-functions.js on lines 116..123

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

      static hiragana( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !HIRAGANA_REGEXP.test(value) ) {
            return {type : "NOT_HIRAGANA"};
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 76..83
    sites/src/js/utils/validation/validation-functions.js on lines 84..91
    sites/src/js/utils/validation/validation-functions.js on lines 92..99
    sites/src/js/utils/validation/validation-functions.js on lines 100..107
    sites/src/js/utils/validation/validation-functions.js on lines 108..115

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

      static number( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( typeof value !== "string" ) return null;
        if ( !NUMBER_REGEXP.test(value) ) {
            return {type : "NOT_NUMBER"};
    Severity: Major
    Found in sites/src/js/utils/validation/validation-functions.js and 5 other locations - About 1 hr to fix
    sites/src/js/utils/validation/validation-functions.js on lines 76..83
    sites/src/js/utils/validation/validation-functions.js on lines 92..99
    sites/src/js/utils/validation/validation-functions.js on lines 100..107
    sites/src/js/utils/validation/validation-functions.js on lines 108..115
    sites/src/js/utils/validation/validation-functions.js on lines 116..123

    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

        if ( restriction.max && value > restriction.max ) {
          return { type: "RANGE", max: restriction.max, min:restriction.min};
        }
    Severity: Minor
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 45 mins to fix
    sites/src/js/utils/validation/validation-functions.js on lines 188..190

    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 ( restriction.min && value < restriction.min ) {
          return { type: "RANGE", max: restriction.max, min:restriction.min};
        }
    Severity: Minor
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 45 mins to fix
    sites/src/js/utils/validation/validation-functions.js on lines 185..187

    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

      static maxLength( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( value.length > restriction ) {
          return { type : "MAX_LENGTH", maxLength: restriction };
        }
    Severity: Minor
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 35 mins to fix
    sites/src/js/utils/validation/validation-functions.js on lines 49..55

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

    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

      static minLength( value, restriction ) {
        if ( isNil(value) ) return null;
        if ( value.length < restriction ) {
          return { type : "MIN_LENGTH", minLength: restriction };
        }
    Severity: Minor
    Found in sites/src/js/utils/validation/validation-functions.js and 1 other location - About 35 mins to fix
    sites/src/js/utils/validation/validation-functions.js on lines 42..48

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

    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

    Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
    Open

    export default class ValidationFunctions {

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status