fogine/json-inspector

View on GitHub

Showing 32 of 74 total issues

File assertions.js has 843 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _               = require('lodash');
var stringValidator = require('validator');

ValidatorError = require('./error/validatorError.js');

Severity: Major
Found in lib/assertions.js - About 2 days to fix

    exports has 46 functions (exceeds 20 allowed). Consider refactoring.
    Open

    var assertions = module.exports = {
        is: function() {
            if (this.filter === Object || this.filter === isMap[Object]) {
                this.success = _.isPlainObject(this.val);
            } else if (this.filter === Array || this.filter === isMap[Array]) {
    Severity: Minor
    Found in lib/assertions.js - About 6 hrs to fix

      File validator.js has 408 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var _                    = require('lodash');
      var queryString          = require('qs');
      var stringValidator      = require('validator');
      var ValidatorError       = require('./error/validatorError.js');
      var ValidationError      = require('./error/validationError.js');
      Severity: Minor
      Found in lib/validator.js - About 5 hrs to fix

        Function build has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Validator.prototype.build = function(data, where, options, parentDataObj, parentProp, parentTreeObj) {
        
            var self = this;
        
            var pool = [];
        Severity: Major
        Found in lib/validator.js - About 4 hrs to fix

          Function filterData has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

          Validator.prototype.filterData = function(data, filter, callback) {
          
              if (_.isPlainObject(data)) {
                  var allowedKeys = Object.keys(filter);
                  var dataKeys = Object.keys(data);
          Severity: Minor
          Found in lib/validator.js - About 4 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 getExpressInjector has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function getExpressInjector(options) {
          
              options = options || {};
          
              // validator definitions
          Severity: Major
          Found in lib/expressInjectorMiddleware.js - About 2 hrs to fix

            Function like has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                like: function() {
                    var keywordAny = (this.keywordPrefix || '') + 'any';
            
                    if (_.isPlainObject(this.filter) && this.filter[keywordAny] instanceof Array) {
                        for (var i = 0, len = this.filter[keywordAny].length; i < len; i++) {
            Severity: Minor
            Found in lib/assertions.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 like has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                like: function() {
                    var keywordAny = (this.keywordPrefix || '') + 'any';
            
                    if (_.isPlainObject(this.filter) && this.filter[keywordAny] instanceof Array) {
                        for (var i = 0, len = this.filter[keywordAny].length; i < len; i++) {
            Severity: Minor
            Found in lib/assertions.js - About 1 hr to fix

              Function validate has 45 lines of code (exceeds 25 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 1 hr to fix

                Function getExpressInjector has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                function getExpressInjector(options) {
                
                    options = options || {};
                
                    // validator definitions
                Severity: Minor
                Found in lib/expressInjectorMiddleware.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 and has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function and(opt) {
                    opt = opt || {};
                
                    return function() {
                        var assertions = this.pool;
                Severity: Minor
                Found in lib/conditions.js - About 1 hr to fix

                  Function hasLengthOf has 39 lines of code (exceeds 25 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 1 hr to fix

                    Function or has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function or(opt) {
                        opt = opt || {};
                    
                        return function() {
                            var assertions = this.pool;
                    Severity: Minor
                    Found in lib/conditions.js - About 1 hr to fix

                      Function filterData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      Validator.prototype.filterData = function(data, filter, callback) {
                      
                          if (_.isPlainObject(data)) {
                              var allowedKeys = Object.keys(filter);
                              var dataKeys = Object.keys(data);
                      Severity: Minor
                      Found in lib/validator.js - About 1 hr to fix

                        Function validatorMiddleware has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function validatorMiddleware(req, res, next) {
                        
                                var valManager = new ValidatorManager();
                        
                                //builds new Validators from validator json schema definitions
                        Severity: Minor
                        Found in lib/expressInjectorMiddleware.js - About 1 hr to fix

                          Function Validator has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function Validator(schema, options, valManager) {
                              var defaults = {
                                  context              : {},
                                  required             : false,
                                  sanitizers           : [],
                          Severity: Minor
                          Found in lib/validator.js - About 1 hr to fix

                            Function buildArrayCondition has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            Validator.prototype.buildArrayCondition = function(prop, data, where, options, parentTreeObj) {
                                var andCondPool = [];
                                var keywordPrefix = options.keywordPrefix;
                                var requiredKeyword = keywordPrefix + 'required';
                                var messageKeyword = keywordPrefix + 'message';
                            Severity: Minor
                            Found in lib/validator.js - About 1 hr to fix

                              Function buildArrayCondition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Validator.prototype.buildArrayCondition = function(prop, data, where, options, parentTreeObj) {
                                  var andCondPool = [];
                                  var keywordPrefix = options.keywordPrefix;
                                  var requiredKeyword = keywordPrefix + 'required';
                                  var messageKeyword = keywordPrefix + 'message';
                              Severity: Minor
                              Found in lib/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 is has 28 lines of code (exceeds 25 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 1 hr to fix

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

                                function recursivelyIterate(entity, callback) {
                                
                                    if (typeof entity === 'string'){
                                        entity = callback(entity);
                                    } else if( _.isPlainObject(entity) ) {
                                Severity: Minor
                                Found in lib/sanitizers.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

                                Severity
                                Category
                                Status
                                Source
                                Language