Showing 156 of 357 total issues
Avoid deeply nested control flow statements. Open
if (correspondingAttrDef.autoCreatedAt || correspondingAttrDef.autoUpdatedAt) {
// Ensure we are not trying to set it to empty string
// (this would never make sense.)
if (value === '') {
Avoid deeply nested control flow statements. Open
if (modifier.length === 0) {
throw flaverr('E_CONSTRAINT_WOULD_MATCH_EVERYTHING', new Error(
'Since this `nin` ("not in") modifier is an empty array, it would match ANYTHING.'
));
}//-•
Avoid deeply nested control flow statements. Open
if (!_.isUndefined(singleJoin.criteria.limit)) {
baseChildTableQuery.criteria.limit = singleJoin.criteria.limit;
} else {
baseChildTableQuery.criteria.limit = Number.MAX_SAFE_INTEGER||9007199254740991;
}
Avoid deeply nested control flow statements. Open
if (_.isNull(value)) {
// We allow `null` for singular associations UNLESS they are required.
if (correspondingAttrDef.required) {
throw flaverr('E_REQUIRED', new Error(
Avoid deeply nested control flow statements. Open
if (_.isUndefined(record[attrName])) {
}
// If the value for this singular association came back as an array, then
// that might be ok too-- it probably means that the association was populated.
else if (_.isArray(record[attrName])) {
Avoid deeply nested control flow statements. Open
if (_.keys(singleJoin.criteria.where).length > 0) {
// If the "where" clause has an "and" modifier already, just push it onto our "and".
if (singleJoin.criteria.where.and) {
baseChildTableQuery.criteria.where.and = baseChildTableQuery.criteria.where.and.concat(singleJoin.criteria.where.and);
} else {
Avoid deeply nested control flow statements. Open
if (!_.isUndefined(singleJoin.criteria.sort)) {
baseChildTableQuery.criteria.sort = singleJoin.criteria.sort;
}
else {
baseChildTableQuery.criteria.sort = [];
Avoid deeply nested control flow statements. Open
if (err) { return nextSetOfJoins(err); }
Avoid deeply nested control flow statements. Open
if (!ThroughWLModel.attributes[attrDef.via]) {
throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) is a "through" association, because it declares a `through`. But the association\'s specified `via` ('+attrDef.via+'`) does not correspond with a recognized attribute on the junction model (`'+attrDef.through+'`)');
}
Avoid deeply nested control flow statements. Open
if (!_.isString(correspondingAttrDef.type) || correspondingAttrDef.type === '') {
throw new Error('Consistency violation: There is no way this attribute (`'+supposedAttrName+'`) should have been allowed to be registered with neither a `type`, `model`, nor `collection`! Here is the attr def: '+util.inspect(correspondingAttrDef, {depth:5})+'');
}
Avoid deeply nested control flow statements. Open
switch (e.code) {
case 'E_VALUE_NOT_USABLE': throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error('Invalid item within `nin` ("not in") modifier array. '+e.message));
default: throw e;
}
Avoid deeply nested control flow statements. Open
if (!OtherWLModel.attributes[attrDef.via]) {
throw new Error('Consistency violation: The referenced attribute (`'+attrName+'`, from model `'+modelIdentity+'`) is an association, because it declares a `collection`. But that association also specifies a `via` ('+attrDef.via+'`) which does not correspond with a recognized attribute on the other model (`'+attrDef.collection+'`)');
}
Avoid deeply nested control flow statements. Open
if (correspondingAttrDef.allowNull && _.isNull(value)) {
// Nothing else to validate here.
}
//‡
// Otherwise, verify that this value matches the expected type, and potentially
Function stream
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function stream( /* criteria?, eachRecordFn?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
- 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 count
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function count( /* criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
- 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 (secondJoin.criteria.where.and) {
baseChildTableQuery.criteria.where.and = baseChildTableQuery.criteria.where.and.concat(secondJoin.criteria.where.and);
}
else {
// Otherwise push the whole "where" clause in to the "and" array as a new conjunct.
Avoid deeply nested control flow statements. Open
if (_.isNull(item)){
throw flaverr('E_CONSTRAINT_NOT_USABLE', new Error(
'Got unsupported value (`null`) in a `nin` ("not in") modifier array. Please use `or: [{ '+constraintTarget+': { \'!=\': null }, ...]` instead.'
));
}//-•
Avoid deeply nested control flow statements. Open
if (singleJoin.collection === true) {
parentRecord[alias] = childTableResults || [];
}
// Otherwise, if this is a to-one join, add the single result to the join key column
Avoid deeply nested control flow statements. Open
else if (modifierKind === '>') {
// If it matches a known attribute, verify that the attribute does not declare
// itself `type: 'boolean'` (it wouldn't make any sense to attempt that)
if (attrDef && attrDef.type === 'boolean'){
Function isExclusive
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function isExclusive(attrName, modelIdentity, orm) {
if (!_.isString(attrName)) {
throw new Error('Consistency violation: Must specify `attrName` as a string. But instead, got: '+util.inspect(attrName, {depth:5})+'');
}
- 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"