Showing 156 of 357 total issues
Function normalizeSortClause
has 208 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function normalizeSortClause(sortClause, modelIdentity, orm, meta) {
// Look up the Waterline model for this query.
// > This is so that we can reference the original model definition.
var WLModel = getModel(modelIdentity, orm);
Function stream
has 194 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function stream( /* criteria?, eachRecordFn?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function createEach
has 191 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function createEach( /* newRecords?, explicitCbMaybe?, meta? */ ) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
File waterline.js
has 484 lines of code (exceeds 250 allowed). Consider refactoring. Open
// ██╗ ██╗ █████╗ ████████╗███████╗██████╗ ██╗ ██╗███╗ ██╗███████╗
// ██║ ██║██╔══██╗╚══██╔══╝██╔════╝██╔══██╗██║ ██║████╗ ██║██╔════╝
// ██║ █╗ ██║███████║ ██║ █████╗ ██████╔╝██║ ██║██╔██╗ ██║█████╗
// ██║███╗██║██╔══██║ ██║ ██╔══╝ ██╔══██╗██║ ██║██║╚██╗██║██╔══╝
// ╚███╔███╔╝██║ ██║ ██║ ███████╗██║ ██║███████╗██║██║ ╚████║███████╗
Function normalizeCriteria
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function normalizeCriteria(criteria, modelIdentity, orm, meta) {
// Sanity checks.
// > These are just some basic, initial usage assertions to help catch
// > bugs during development of Waterline core.
- 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 addToCollection
has 184 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function addToCollection(/* targetRecordIds, collectionAttrName, associatedIds?, explicitCbMaybe?, meta? */) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function removeFromCollection
has 181 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function removeFromCollection(/* targetRecordIds?, collectionAttrName?, associatedIds?, explicitCbMaybe?, meta? */) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
File normalize-constraint.js
has 457 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Module dependencies
*/
var util = require('util');
Function update
has 174 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function update(criteria, valuesToSet, explicitCbMaybe, metaContainer) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function normalizeWhereClause
has 174 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function normalizeWhereClause(whereClause, modelIdentity, orm, meta) {
// Look up the Waterline model for this query.
// > This is so that we can reference the original model definition.
var WLModel = getModel(modelIdentity, orm);
Function _afterRunningBeforeLC
has 164 lines of code (exceeds 25 allowed). Consider refactoring. Open
})(function _afterRunningBeforeLC(err, query) {
if (err) {
return done(err);
}
File normalize-criteria.js
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Module dependencies
*/
var util = require('util');
Function create
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function create(newRecord, explicitCbMaybe, metaContainer) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function normalizePkValue
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function normalizePkValue (pkValue, expectedPkType){
// Check usage
if (expectedPkType !== 'string' && expectedPkType !== 'number') {
throw new Error('Consistency violation: The internal normalizePkValue() utility must always be called with a valid second argument ("string" or "number"). But instead, got: '+util.inspect(expectedPkType, {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"
Further reading
Function Waterline
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
function Waterline() {
// Start by setting up an array of model definitions.
// (This will hold the raw model definitions that were passed in,
// plus any implicitly introduced models-- but that part comes later)
- 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
File forge-stage-three-query.js
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Module dependencies
*/
var util = require('util');
Function _afterPotentiallyRunningBeforeLC
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
})(function _afterPotentiallyRunningBeforeLC(err, query) {
if (err) {
return done(err);
}
Function normalizeNewRecord
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function normalizeNewRecord(newRecord, modelIdentity, orm, currentTimestamp, meta) {
// Tolerate this being left undefined by inferring a reasonable default.
// Note that we can't bail early, because we need to check for more stuff
// (there might be required attrs!)
Function forgeAdapterError
has 123 lines of code (exceeds 25 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!');
Function _recursiveStep
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
(function _recursiveStep(branch, recursionDepth, parent, indexInParent){
var MAX_RECURSION_DEPTH = 25;
if (recursionDepth > MAX_RECURSION_DEPTH) {
throw flaverr('E_WHERE_CLAUSE_UNUSABLE', new Error('This `where` clause seems to have a circular reference. Aborted automatically after reaching maximum recursion depth ('+MAX_RECURSION_DEPTH+').'));