Showing 28 of 53 total issues
Function exports
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function( grunt ) {
var dbTarget = grunt.option( 'module' ) || null
, defaultConfig = require( path.join( __dirname, 'config', 'default.json' ) )
, configFile = null
, config = {};
Function defineAssociations
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function defineAssociations(models) {
/*jshint validthis: true */
var cleverOdm = this
, modelNames = Object.keys(models);
- 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 associateModels
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
function associateModels(callback) {
async.forEachSeries(
Object.keys(seedData),
function forEachSeedDataModel(modelName, cb) {
var ModelType = models[modelName.replace('Model', '')]
Function forEachSeedDataModel
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
function forEachSeedDataModel(modelName, cb) {
var ModelType = models[modelName.replace('Model', '')]
, Models = seedData[modelName];
if (!ModelType || !Models || ModelType.type !== 'ODM') {
Function associateModel
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
function associateModel(data, modelCb) {
if (data.associations !== undefined) {
var assocLength = Object.keys(data.associations).length
, called = 0
, model = _.findWhere(assocMap[modelName], { id: data.id });
Function defineField
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
defineField: function(Klass, fields, mongooseConf, name) {
var fieldDefinition = {}
, columnName = name
, options = Klass.fields[name];
- 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 defineField
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
defineField: function(Klass, fields, mongooseConf, name) {
var fieldDefinition = {}
, columnName = name
, options = Klass.fields[name];
Function belongsTo
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function belongsTo(mongoose, Klass, Proto, assocTo) {
assocTo = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
if (Klass.primaryKeys.length !== 1) {
throw new Error('belongsTo association not support without primaryKeys.');
Function hasMany
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function hasMany(mongoose, Klass, Proto, assocTo) {
assocTo = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
if (Klass.primaryKeys.length !== 1) {
throw new Error('hasMany association not support without primaryKeys.');
Function createModels
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createModels(callback) {
async.forEachSeries(
Object.keys(seedData),
function forEachSeedDataModel(modelName, cb) {
var ModelType = models[modelName.replace('Model', '')]
Function defineAssociationAccessors
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {
console.dir(arguments);
process.exit(1);
var accessors = this[assocType]
, singular = inflect.singularize(alias)
Function belongsTo
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function belongsTo(mongoose, Klass, Proto, assocTo) {
assocTo = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
if (Klass.primaryKeys.length !== 1) {
throw new Error('belongsTo association not support without primaryKeys.');
- 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 hasOne
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function hasOne(mongoose, model, proto, assocTo) {
assocTo = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
var targetModelName = assocTo.shift()
, associationOptions = assocTo.shift()
Function defineAssociations
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function defineAssociations(models) {
/*jshint validthis: true */
var cleverOdm = this
, modelNames = Object.keys(models);
Function hasMany
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function hasMany(mongoose, Klass, Proto, assocTo) {
assocTo = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
if (Klass.primaryKeys.length !== 1) {
throw new Error('hasMany association not support without primaryKeys.');
- 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 getFieldType
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFieldType: function(Klass, options, name) {
var field;
switch(options.type) {
Function parseModelSchema
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseModelSchema: function(Klass, Proto) {
var parseDebug = this.proxy(function(msg) {
this.debug(Klass.modelName + 'Model: ' + msg);
})
, mongooseConf = {}
Function forEachSeedDataModel
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function forEachSeedDataModel(modelName, cb) {
var ModelType = models[modelName.replace('Model', '')]
, Models = seedData[modelName];
if (!ModelType || !Models || ModelType.type !== 'ODM') {
Function eachSourceModel
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
modelNames.forEach(function eachSourceModel(sourceModelName) {
var associationTypes = Object.keys(models[sourceModelName]);
associationTypes.forEach(function eachAssociationType(assocType) {
var targets = models[sourceModelName][assocType];
Function eachAssociationType
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
associationTypes.forEach(function eachAssociationType(assocType) {
var targets = models[sourceModelName][assocType];
if (!(targets instanceof Array)) {
targets = [targets];