lib/shared/Validator.js

Summary

Maintainability
D
1 day
Test Coverage

Function getType has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  static getType(object) {
    var type = typeof object;

    if (type === 'object') {
      if (object === null) {
Severity: Minor
Found in lib/shared/Validator.js - About 2 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 getType has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static getType(object) {
    var type = typeof object;

    if (type === 'object') {
      if (object === null) {
Severity: Minor
Found in lib/shared/Validator.js - About 1 hr to fix

    Function findInOptions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      static findInOptions(option, options, path, recursive = false) {
        let min = 1e9;
        let closestMatch = '';
        let closestMatchPath = [];
        let lowerCaseOption = option.toLowerCase();
    Severity: Minor
    Found in lib/shared/Validator.js - About 1 hr 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 levenshteinDistance has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      static levenshteinDistance(a, b) {
        if (a.length === 0) return b.length;
        if (b.length === 0) return a.length;
    
        var matrix = [];
    Severity: Minor
    Found in lib/shared/Validator.js - About 1 hr 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 findInOptions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static findInOptions(option, options, path, recursive = false) {
        let min = 1e9;
        let closestMatch = '';
        let closestMatchPath = [];
        let lowerCaseOption = option.toLowerCase();
    Severity: Minor
    Found in lib/shared/Validator.js - About 1 hr to fix

      Function printLocation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        static printLocation(path, option, prefix = 'Problem value found at: \n') {
          let str = '\n\n' + prefix + 'options = {\n';
          for (let i = 0; i < path.length; i++) {
            for (let j = 0; j < i + 1; j++) {
              str += '  ';
      Severity: Minor
      Found in lib/shared/Validator.js - About 35 mins 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

      Avoid too many return statements within this function.
      Open

            return 'string';
      Severity: Major
      Found in lib/shared/Validator.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return 'number';
        Severity: Major
        Found in lib/shared/Validator.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return type;
          Severity: Major
          Found in lib/shared/Validator.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return 'date';
            Severity: Major
            Found in lib/shared/Validator.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return 'object';
              Severity: Major
              Found in lib/shared/Validator.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return 'array';
                Severity: Major
                Found in lib/shared/Validator.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return 'moment';
                  Severity: Major
                  Found in lib/shared/Validator.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return 'boolean';
                    Severity: Major
                    Found in lib/shared/Validator.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return 'undefined';
                      Severity: Major
                      Found in lib/shared/Validator.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return 'dom';
                        Severity: Major
                        Found in lib/shared/Validator.js - About 30 mins to fix

                          Function check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                            static check(option, options, referenceOptions, path) {
                              if (referenceOptions[option] === undefined && referenceOptions.__any__ === undefined) {
                                Validator.getSuggestion(option, referenceOptions, path);
                                return;
                              }
                          Severity: Minor
                          Found in lib/shared/Validator.js - About 25 mins 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

                          TODO found
                          Open

                                // TODO: Examine if needed, remove if possible
                          Severity: Minor
                          Found in lib/shared/Validator.js by fixme

                          There are no issues that match your filters.

                          Category
                          Status