Showing 19 of 28 total issues
Function validateObject
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
var validateObject = function(param, value, models) {
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
}
Function validate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var validate = function(param, value, models) {
var type = param.uniqueItems ? "set" : "array";
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
Function validateString
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
var validateString = function(param, value) {
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
}
- 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 func
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var func = function(param, value) {
var model = models[param.type];
// it is probably irrelevant to check as a model without properties is pointless, but it is a nice sanity check
if (model.properties) {
Function validateInt64
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var validateInt64 = function(param, value) {
var type = param.format ? param.format : param.type;
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
- 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 validateInteger
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var validateInteger = function(param, value) {
var type = param.format ? param.format : param.type;
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
- 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 validateNumber
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
var validateNumber = function(param, value) {
var type = param.format ? param.format : param.type;
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
- 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 validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
var validate = function(param, value, models) {
var type = param.uniqueItems ? "set" : "array";
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
- 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 isRequired
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function isRequired(param, value) {
if (_.isUndefined(value) || _.isNull(value) || value === '') {
var isParamRequired = param.required && !param.defaultValue;
return isParamRequired
? errorReturn("%s is required", param.name)
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var validate = function(spec, req, models) {
var ret = [];
var isSpecObject = Object.prototype.toString.call(spec) === '[object Object]';
var validationObj = makeValidationObject(isSpecObject ? spec.validation : {});
- 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 validateObject
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var validateObject = function(param, value, models) {
var isRequired = helper.isRequired(param, value);
if (isRequired) {
return isRequired;
}
- 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
Consider simplifying this complex logical expression. Open
if (isNaN(val) || !isFinite(val) || _.isArray(value) || _.isBoolean(value) || (_.isString(value) && value.trim() === '')) {
return helper.errorReturn("%s is not a type of %s", [param.name, type]);
}
Consider simplifying this complex logical expression. Open
if (req.query === undefined && req.path === undefined && req.body === undefined
&& req.form === undefined && req.header === undefined && req.params === undefined) {
return paramTypes.object(param, req, models, validationObj);
}
Avoid too many return
statements within this function. Open
return helper.successReturn(val);
Avoid too many return
statements within this function. Open
return helper.errorReturn("%s is not valid based on the pattern %s", [param.name, param.pattern]);
Avoid too many return
statements within this function. Open
return helper.errorReturn("%s is specified with an invalid pattern %s", [param.name, param.pattern]);
Avoid too many return
statements within this function. Open
return helper.successReturn(val);
Avoid too many return
statements within this function. Open
return helper.successReturn(val);
Avoid too many return
statements within this function. Open
return helper.successReturn(value);