Showing 156 of 357 total issues
Function getModel
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function getModel(modelIdentity, orm) {
// ================================================================================================
// Check that this utility function is being used properly, and that the provided `modelIdentity` and `orm` are valid.
if (!_.isString(modelIdentity) || modelIdentity === '') {
- 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 _afterPotentiallyRunningBeforeLC
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
})(function _afterPotentiallyRunningBeforeLC(err, query) {
if (err) {
return done(err);
}
Function _maybeWipeAssociatedCollections
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
(function _maybeWipeAssociatedCollections(proceed) {
// If `cascade` meta key is NOT enabled, then just proceed.
if (!query.meta || !query.meta.cascade) {
return proceed();
Function _maybeTransformRecords
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
(function _maybeTransformRecords(proceed){
// If `fetch` was not enabled, return.
if (!_.has(query.meta, 'fetch') || query.meta.fetch === false) {
Function forgeAdapterError
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function forgeAdapterError(err, omen, adapterMethodName, modelIdentity, orm){
try {
// Sanity checks
assert(err, 'Should never call `forgeAdapterError` with a falsy first argument!');
- 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 _afterFetchingRecords
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpFind(WLModel, query, omen, function _afterFetchingRecords(err, populatedRecords) {
if (err) {
return done(err);
}//-•
// console.log('result from operation runner:', record);
Function normalizePkValueOrValues
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function normalizePkValueOrValues (pkValueOrPkValues, expectedPkType){
// Check usage
if (expectedPkType !== 'string' && expectedPkType !== 'number') {
throw new Error('Consistency violation: The internal normalizePkValueOrValues() utility must always be called with a valid second argument ("string" or "number"). But instead, got: '+util.inspect(expectedPkType, {depth:5})+'');
Function populate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
populate: function(keyName, subcriteria) {
assert(this._wlQueryInfo.method === 'find' || this._wlQueryInfo.method === 'findOne' || this._wlQueryInfo.method === 'stream', 'Cannot chain `.populate()` onto the `.'+this._wlQueryInfo.method+'()` method. (In fact, this shouldn\'t even be possible! So the fact that you are seeing this message at all is, itself, likely due to a bug in Waterline.)');
// Backwards compatibility for arrays passed in as `keyName`.
Function _eachRecordInBatch
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async.eachSeries(batchOfRecords, function _eachRecordInBatch(record, next) {
// Note that, if you try to call next() more than once in the iteratee, Waterline
// logs a warning explaining what's up, ignoring all subsequent calls to next()
// that occur after the first.
var didIterateeAlreadyHalt;
Function validate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function validate(attrName, value) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function sum
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function sum( /* numericAttrName?, 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
Function avg
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function avg( /* numericAttrName?, 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
Function start
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
module.exports.start = function (options, done){
// Verify usage & apply defaults:
if (!_.isFunction(done)) {
throw new Error('Please provide a valid callback function as the 2nd argument to `Waterline.start()`. (Instead, got: `'+done+'`)');
- 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 _afterFinding
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
WLModel.find(s2qCriteriaForFind, function _afterFinding(err, foundRecords) {
if (err) { return done(err); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FUTURE: as an optimization, fetch records batch-at-a-time
Function _maybeFindIdsToDestroy
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
(function _maybeFindIdsToDestroy(proceed) {
// If `cascade` meta key is NOT enabled, then just proceed.
if (!query.meta || !query.meta.cascade) {
return proceed();
Function hasSchemaCheck
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function hasSchemaCheck(context) {
// If hasSchema is defined on the collection, return the value
if (_.has(Object.getPrototypeOf(context), 'hasSchema')) {
var proto = Object.getPrototypeOf(context);
if (!_.isUndefined(proto.hasSchema)) {
- 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 CollectionBuilder
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function CollectionBuilder(collection, datastores, context) {
// ╦ ╦╔═╗╦ ╦╔╦╗╔═╗╔╦╗╔═╗
// ╚╗╔╝╠═╣║ ║ ║║╠═╣ ║ ║╣
// ╚╝ ╩ ╩╩═╝╩═╩╝╩ ╩ ╩ ╚═╝
- 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 (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
else if (attrDef.autoCreatedAt || attrDef.autoUpdatedAt) {
assert(!attrDef.allowNull, 'Timestamp attributes should never be defined with `allowNull:true`. (This should have already been caught in wl-schema during ORM initialization! Please report this at http://sailsjs.com/bugs)');
// If there is no value defined on the record for this attribute...
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