fogine/json-inspector

View on GitHub

Showing 32 of 74 total issues

Function is has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    is: function() {
        if (this.filter === Object || this.filter === isMap[Object]) {
            this.success = _.isPlainObject(this.val);
        } else if (this.filter === Array || this.filter === isMap[Array]) {
            this.success = this.val instanceof Array;
Severity: Minor
Found in lib/assertions.js - About 55 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

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

Validator.prototype.build = function(data, where, options, parentDataObj, parentProp, parentTreeObj) {
Severity: Minor
Found in lib/validator.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (fun instanceof Function) {
                    pool.push(fun);
                }
    Severity: Major
    Found in lib/validator.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

              } else if (_.isPlainObject(where[prefixedProp]) )  {
      
                  var required = where.hasOwnProperty(requiredKeyword) ? where[requiredKeyword] : options.required;
                  var nullable = where.hasOwnProperty(nullableKeyword) ? where[nullableKeyword] : options.nullable;
      
      
      Severity: Major
      Found in lib/validator.js - About 45 mins to fix

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

        Validator.prototype.addSanitizer = function(sanitizerProp, where, parentDataObj, parentProp, options) {
        Severity: Minor
        Found in lib/validator.js - About 35 mins to fix

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

          Validator.prototype.buildArrayCondition = function(prop, data, where, options, parentTreeObj) {
          Severity: Minor
          Found in lib/validator.js - About 35 mins to fix

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

            Validator.prototype.buildObjectCondition = function(prop, data, where, options, parentTreeObj) {
            Severity: Minor
            Found in lib/validator.js - About 35 mins to fix

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

                  hasLengthOf: function() {
                      if (this.val instanceof Array) {
                          var defaults = {
                              min: 0,
                              max: undefined
              Severity: Minor
              Found in lib/assertions.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

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

              Validator.prototype.buildObjectCondition = function(prop, data, where, options, parentTreeObj) {
                  var path = options.propPath ? options.propPath + '.' + prop : prop;
                  var keywordPrefix = options.keywordPrefix;
                  var requiredKeyword = keywordPrefix + 'required';
                  var messageKeyword = keywordPrefix + 'message';
              Severity: Minor
              Found in lib/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

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

              Validator.prototype.validate = function(data, customSchema, options) {
                  var self = this;
                  options = options || {};
              
                  this.error = null; //TODO ?
              Severity: Minor
              Found in lib/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;
              Severity: Major
              Found in lib/validator.js - About 30 mins to fix

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

                function minMaxOrBoth(def, opt, context) {
                    var out = def.both;
                
                    if (_.isPlainObject(opt)) {
                        context.min = opt.min;
                Severity: Minor
                Found in lib/assertions.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

                Severity
                Category
                Status
                Source
                Language