Showing 220 of 414 total issues
Avoid deeply nested control flow statements. Open
if (value !== undefined) {
_.set(target, f, value);
}
Function routeConfigurationCheck
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function routeConfigurationCheck(config, method) {
var routesRestrictions = injector.config.env.restrictions || {};
var allowed = true;
if ((routesRestrictions.blacklist && routesRestrictions.blacklist.routes) || (routesRestrictions.whitelist && routesRestrictions.whitelist.routes)) {
- 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 walkSchema
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function walkSchema(app, Model, schema, parentName, fromArray, rawPath) {
Avoid deeply nested control flow statements. Open
if (i == 0) {
fileName = sourceFileName;
} else {
fileName = addStringBeforeExtension(sourceFileName, '_' + i);
}
Function TypeBased
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var TypeBased = /** @class */ (function () {
function TypeBased() {
}
//TODO: Add hooks and middlewares
TypeBased.directReference = function (model, field, refModel, refField) {
- 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
Avoid deeply nested control flow statements. Open
for (let field of Model.schema.paths[key].options.denormalize)
validFields.push(key + "." + field);
Avoid deeply nested control flow statements. Open
if (i == 0) {
fileName = sourceFileName;
} else {
fileName = addStringBeforeExtension(sourceFileName, '_' + i);
}
Avoid deeply nested control flow statements. Open
for (var i in doc) {
if (doc.hasOwnProperty(i)) {
//Prune all the elements in the object
doc[i] = prune(doc[i]);
}
Function injectRefs
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function injectRefs(app, baseConfig, refConfig, Model, refModel, key) {
Avoid deeply nested control flow statements. Open
if (e) {
log.error(e);
res.json(e);
res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
return res.end();
Function injectArrays
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function injectArrays(app, field, key, Model, baseConfig, rawPath) {
Avoid deeply nested control flow statements. Open
if (i == 0) {
fileName = sourceFileName;
} else {
fileName = addStringBeforeExtension(sourceFileName, '_' + i);
}
Avoid deeply nested control flow statements. Open
if (e) {
log.error(e);
res.json(e);
res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
return res.end();
Avoid deeply nested control flow statements. Open
if (parent) {
var child = element.substring(parentPath.length + 1);
return module.exports.getElementSchema(parent.schema.paths, child);
}
Avoid deeply nested control flow statements. Open
if (Object.keys(objDoc).length > 0) {
for (var i in objDoc) {
if (objDoc.hasOwnProperty(i)) {
//Prune all the elements in the object
//Although we are working with the plain object, we COPY and PRUNE the original object
Function getInvRefField
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports.getInvRefField = function (Model, refModel, field) {
return function (req, res) {
var gConfig = Model.injector();
var config = utils.getConfigByProfile(gConfig.get, req);
(config.pre) ? utils.runPreCallbacks(config.pre, Model, req, res, mainGetFn) : mainGetFn();
- 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
Avoid deeply nested control flow statements. Open
if (objDoc == null || objDoc == undefined) {
//Null objects marked as undefined
doc = undefined;
}
Function injectArrays
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function injectArrays(app, field, key, Model, baseConfig, rawPath) {
log.debug("Inject array methods for model " + Model.modelName + " and field " + key);
//app.get(gConfig.apiBasePath + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key, refs.getAllArray(Model, key));
//app.get(gConfig.apiBasePath + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key + '/:index', refs.getArrayElementAt(Model, key));
- 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
Avoid deeply nested control flow statements. Open
if (e) {
log.error(e);
res.json(e);
res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
return res.end();
Avoid deeply nested control flow statements. Open
if (parentPath) {
parentPath += "." + chunk
} else {
parentPath = chunk;
}