Showing 125 of 296 total issues
Function load
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function load(relations, options, cb) {
var models = container.get('models');
var Model = this.constructor;
var newModels = {};
var merge = {};
Function sanitize
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return Promise.resolve().then(function sanitize() {
if (!utils.isArray(keys)) {
throw new IllegalArgumentError(errorPrefix + 'keys: Must be a string or an array!', { actual: typeof keys, expected: 'string|array' });
} else if (!utils.isString(index) && !utils.isObject(index)) {
throw new IllegalArgumentError(errorPrefix + 'index: Must be a string or an object!', { actual: typeof index, expected: 'string|object' });
Function softDeleteTimestamps
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
softDeleteTimestamps: function (test) {
test.expect(7);
var instance = {
attributes: {
Function exports
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function (container, Promise, utils, errors) {
var errorPrefix = 'Collection.getAll(keys, index[, options][, cb]): ';
var IllegalArgumentError = errors.IllegalArgumentError;
var RuntimeError = errors.RuntimeError;
- 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 destroy.test.js
has 327 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*jshint loopfunc:true*/
var SandboxedModule = require('sandboxed-module'),
errors = require('../../../../../build/instrument/lib/support/errors'),
Promise = require('bluebird'),
Function exports
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
Open
module.exports = function (Collection_save, utils, errors, Promise) {
var protoProps = {
/**
- 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 exports
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (Promise, utils, errors, models) {
/**
* @doc method
* @id Model.instance_methods:destroy
* @name destroy
Function softDelete
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
softDelete: function (test) {
test.expect(7);
var instance = {
attributes: {
Function setUp
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setUp: function (cb) {
connection = new Connection();
connection.run(r.dbList())
.then(function (dbList) {
if (utils.contains(dbList, 'test')) {
Function setUp
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setUp: function (cb) {
connection = new Connection();
connection.run(r.dbList())
.then(function (dbList) {
if (utils.contains(dbList, 'test')) {
Function evaluateRelations
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function evaluateRelations() {
utils.forOwn(models, function (model, modelName) {
if ('hasOne' in model.relations && !utils.isObject(model.relations.hasOne)) {
throw new errors.IllegalArgumentError(errorPrefix + modelName + '.relations.hasOne: Must be an object!', { actual: typeof model.relations.hasOne, expected: 'object' });
} else if ('belongsTo' in model.relations && !utils.isObject(model.relations.belongsTo)) {
Function destroy
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function destroy(options, cb) {
var Model = this.constructor;
var tasks = [];
if (utils.isFunction(options)) {
cb = options;
Function exports
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function (container, Promise, utils, errors) {
/**
* @doc method
* @id Model.static_methods:destroyOne
* @name destroyOne
Function destroyOne
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function destroyOne(primaryKey, options, cb) {
var models = container.get('models');
var query;
var Model = this;
File index.test.js
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*jshint loopfunc:true*/
var prototype = require('../../../../../build/instrument/lib/model/prototype'),
errors = require('../../../../../build/instrument/lib/support/errors'),
utils = require('../../../../../build/instrument/lib/support/utils'),
Function defineModel
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
defineModel: function (test) {
test.expect(42);
for (var i = 0; i < support.TYPES_EXCEPT_STRING.length; i++) {
test.throws(
Function timestampsIsNew
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
timestampsIsNew: function (test) {
test.expect(5);
var instance = {
attributes: {
Function timestampsNotNew
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
timestampsNotNew: function (test) {
test.expect(5);
var instance = {
attributes: {
Function normal
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
normal: function (test) {
test.expect(7);
var instance = {
attributes: {
File save.test.js
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*jshint loopfunc:true*/
var SandboxedModule = require('sandboxed-module'),
errors = require('../../../../../build/instrument/lib/support/errors'),
support = require('../../../../support/support'),