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');
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]) {
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');
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 = [];
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);
- Read upRead up
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
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++) {
- Read upRead up
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++) {
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 ?
Function getExpressInjector
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function getExpressInjector(options) {
options = options || {};
// validator definitions
- Read upRead up
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;
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
Function or
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function or(opt) {
opt = opt || {};
return function() {
var assertions = this.pool;
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);
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
Function Validator
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Validator(schema, options, valManager) {
var defaults = {
context : {},
required : false,
sanitizers : [],
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';
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';
- Read upRead up
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;
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) ) {
- Read upRead up
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"