lib/RouteSchemaManager.js
Function RouteSchemaManager
has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring. Open
Open
var RouteSchemaManager = function(options) {
options = options || {};
var schemasByServerUri = {},
validationTypes = {
- 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 RouteSchemaManager
has 237 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var RouteSchemaManager = function(options) {
options = options || {};
var schemasByServerUri = {},
validationTypes = {
Consider simplifying this complex logical expression. Open
Open
if (forceArrayConversion && schema.type === 'array' && typeof(object) === 'string' && schema.items &&
(schema.items.type === 'string' || schema.items.type === 'number' || schema.items.type === 'integer' || schema.items.type === 'boolean')) {
object = [object];
}
Function convertPropertyTypesToMatchSchema
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
convertPropertyTypesToMatchSchema = function(object, schema, forceArrayConversion) {
// in some cases (query params), we want to force a value to be an array that contains that value,
// if the schema expects an array of strings, numbers, integers, or booleans
if (forceArrayConversion && schema.type === 'array' && typeof(object) === 'string' && schema.items &&
(schema.items.type === 'string' || schema.items.type === 'number' || schema.items.type === 'integer' || schema.items.type === 'boolean')) {
Avoid deeply nested control flow statements. Open
Open
if (schema.properties.hasOwnProperty(subProp)) {
modifiedSchema.properties[subProp.toLowerCase()] = modifyHeadersSchema(schema.properties[subProp]);
}
Avoid deeply nested control flow statements. Open
Open
for (i = 0; i < object.length; i++) {
object[i] = convertPropertyTypesToMatchSchema(object[i], schema.items, forceArrayConversion);
}
Avoid too many return
statements within this function. Open
Open
return value;