Showing 156 of 357 total issues
Function count
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function count( /* criteria?, explicitCbMaybe?, meta?, moreQueryKeys? */ ) {
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function getAttribute
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function getAttribute(attrName, modelIdentity, orm) {
// ================================================================================================
// Check that the provided `attrName` is valid.
// (`modelIdentity` and `orm` will be automatically checked by calling `getModel()`)
Function whenWaterlineIsReady
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
}, function whenWaterlineIsReady (err, orm) {
if (err) {
return done(new Error('Could not start up Waterline ORM: '+err.stack));
}//--•
Function archiveOne
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function archiveOne(criteria, explicitCbMaybe, metaContainer){
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function destroyOne
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function destroyOne(criteria, explicitCbMaybe, metaContainer){
// Verify `this` refers to an actual Sails/Waterline model.
verifyModelMethodContext(this);
Function _afterTalkingToAdapter
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
adapter.update(WLModel.datastore, query, function _afterTalkingToAdapter(err, rawAdapterResult) {
if (err) {
err = forgeAdapterError(err, omen, 'update', modelIdentity, orm);
return done(err);
}//-•
Function normalizePkValue
has 65 lines of code (exceeds 25 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})+'');
Function _afterPotentiallyWipingCollections
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
})(function _afterPotentiallyWipingCollections(err) {// ~∞%°
if (err) {
return done(err);
}
Function processAllRecords
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function processAllRecords(records, meta, modelIdentity, orm) {
// console.time('processAllRecords');
if (!_.isArray(records)) {
- 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 64 lines of code (exceeds 25 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+'`)');
Function paginate
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
paginate: function(pageNumOrOpts, pageSize) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
Function _afterTalkingToAdapter
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
adapter.create(WLModel.datastore, query, function _afterTalkingToAdapter(err, rawAdapterResult) {
if (err) {
err = forgeAdapterError(err, omen, 'create', modelIdentity, orm);
return done(err);
}//-•
File process-all-records.js
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Module dependencies
*/
var assert = require('assert');
File replace-collection.js
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* Module dependencies
*/
var assert = require('assert');
Function serializeCriteria
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Transformation.prototype.serializeCriteria = function(values) {
var self = this;
function recursiveParse(obj) {
Function isCapableOfOptimizedPopulate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function isCapableOfOptimizedPopulate(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"
Further reading
Function recursiveParse
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function recursiveParse(obj) {
// Return if no object
if (!obj) {
return;
Function isCapableOfOptimizedPopulate
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function isCapableOfOptimizedPopulate(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})+'');
}
Function paginate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
paginate: function(pageNumOrOpts, pageSize) {
if (!this._alreadyInitiallyExpandedCriteria) {
this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
this._alreadyInitiallyExpandedCriteria = true;
- 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 getModel
has 42 lines of code (exceeds 25 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 === '') {