CleverStack/node-seed

View on GitHub

Showing 52 of 88 total issues

Function addResource has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  addResource: function(pathToInspect, file, callback) {
    if ((file.match(/.+\.js$/g) !== null || file.match(/.+\.es6$/g) !== null) && this.Class.excludedFiles.indexOf(file) === -1) {
      var folders         = pathToInspect.split(path.sep)
        , name            = file.replace('.js', '').replace('.es6', '')
        , currentFolder   = null
Severity: Minor
Found in lib/classes/Module.js - About 5 hrs to fix

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 aliasAssociationForQuery has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function aliasAssociationForQuery(data, remove, fieldName, callback) {
  var associations    = this.Class ? this.Class.entity.associations : this.entity.associations
    , hasAssociation  = associations ? associations[fieldName] : false
    , isArray         = data[fieldName] instanceof Array;

Severity: Minor
Found in lib/utils/model/helpers/alias/associations/forQuery.js - About 3 hrs to fix

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 a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function defineField(Proto, Klass, fieldName) {
  var prop        = Proto[fieldName]
    , columnName  = !!Klass.underscored ? inflect.underscore(fieldName) : fieldName;
   
  if (!!prop.columnName && fieldName !== prop.columnName) {
Severity: Minor
Found in lib/utils/model/helpers/defineField.js - About 3 hrs to fix

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 Service.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var injector    = require('injector')
  , exceptions  = require('exceptions')
  , Classes     = require('classes')
  , underscore  = require('underscore')
  , Class       = Classes.Class
Severity: Minor
Found in lib/classes/Service.js - About 2 hrs to fix

Function aliasFieldsForQuery has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function aliasFieldsForQuery(fields, callback) {
  if (Object.keys(fields).length > 0) {
    if (debug.enabled) {
      debug(util.format('aliasFieldsForQuery(%s)', utils.model.helpers.debugInspect(fields)));
    }
Severity: Minor
Found in lib/utils/model/helpers/alias/fields/forQuery.js - About 2 hrs to fix

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 addResource has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  addResource: function(pathToInspect, file, callback) {
    if ((file.match(/.+\.js$/g) !== null || file.match(/.+\.es6$/g) !== null) && this.Class.excludedFiles.indexOf(file) === -1) {
      var folders         = pathToInspect.split(path.sep)
        , name            = file.replace('.js', '').replace('.es6', '')
        , currentFolder   = null
Severity: Major
Found in lib/classes/Module.js - About 2 hrs to fix

Function extend has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.extend = function() {
  var extendingArgs   = [].slice.call(arguments)
    , serviceName     = (typeof extendingArgs[ 0 ] === 'string') ? extendingArgs.shift() : false
    , Klass           = (extendingArgs.length === 2) ? extendingArgs.shift() : {}
    , Proto           = extendingArgs.shift();
Severity: Minor
Found in lib/classes/Service.js - About 1 hr to fix

Function aliasAssociationsForOutput has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function aliasAssociationsForOutput(fields, callback) {
  if (this.associations || this.Class.associations) {
    if (debug.enabled) {
      debug(util.format('aliasAssociationsForOutput(%s)', utils.model.helpers.debugInspect(Object.keys(fields))));
    }
Severity: Minor
Found in lib/utils/model/helpers/alias/associations/forOutput.js - About 1 hr to fix

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 update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  update: function(values, queryOptions) {
    values = (typeof values === 'object') ? values : {};
    queryOptions = (typeof queryOptions !== 'object') ? {where:{id: queryOptions}} : queryOptions;
    if (!queryOptions.where) {
      queryOptions = {where: queryOptions};
Severity: Minor
Found in lib/classes/Service.js - About 1 hr to fix

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 loadModules has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  loadModules: function(env, modules) {
    var deps   = this.getEnabledModuleNames()
      , loader = this;

    modules    = modules || this.modules;
Severity: Minor
Found in lib/classes/ModuleLoader.js - About 1 hr to fix

Function defineField has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function defineField(Proto, Klass, fieldName) {
  var prop        = Proto[fieldName]
    , columnName  = !!Klass.underscored ? inflect.underscore(fieldName) : fieldName;
   
  if (!!prop.columnName && fieldName !== prop.columnName) {
Severity: Minor
Found in lib/utils/model/helpers/defineField.js - About 1 hr to fix

Function extend has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  extend: function() {
    var Reg           = new RegExp('.*\\(([^\\)]+)\\:.*\\:.*\\)', 'ig')
      , stack         = new Error().stack.split('\n')
      , extendingArgs = [].slice.call(arguments)
      , Static        = (extendingArgs.length === 2) ? extendingArgs.shift() : {}
Severity: Minor
Found in lib/classes/Module.js - About 1 hr to fix

Function loadResourcesForPath has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function loadResourcesForPath(folderPath) {
  var exists  = fs.existsSync(folderPath)
    , listing = !!exists ? fs.readdirSync(folderPath) : [];

  if (!!exists && listing.length) {
Severity: Minor
Found in lib/utils/magicModule.js - About 1 hr to fix

Function saveModelInstance has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function saveModelInstance(values, queryOptions) {
  var utilName   = this.Class.type.toLowerCase() + 'Utils'
    , helpers    = utils.model.helpers
    , driverUtil = utils[utilName]
    , omitFields;
Severity: Minor
Found in lib/utils/model/instance/save.js - About 1 hr to fix

Function findOrCreateModel has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function findOrCreateModel(findOptions, queryOptions) {
  var helpers        = utils.model.helpers
    , cxtTransaction = false;

  findOptions        = helpers.findOptions.normalize(findOptions);
Severity: Minor
Found in lib/utils/model/findOrCreate.js - About 1 hr to fix

Function isNewModel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function isNewModel(data, callback) {
  if (this.debug.enabled) {
    this.debug(util.format('isNewModel(%s)', utils.model.helpers.debugInspect(data)));
  }

Severity: Minor
Found in lib/utils/model/helpers/isNewModel.js - About 1 hr to fix

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 findOrCreateModel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function findOrCreateModel(findOptions, queryOptions) {
  var helpers        = utils.model.helpers
    , cxtTransaction = false;

  findOptions        = helpers.findOptions.normalize(findOptions);
Severity: Minor
Found in lib/utils/model/findOrCreate.js - About 1 hr to fix

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 findAll has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  findAll: function(idOrFindOptions, queryOptions) {
    idOrFindOptions  = (typeof idOrFindOptions !== 'object') ? {where:{id: idOrFindOptions}} : idOrFindOptions;
    if (!idOrFindOptions.where) {
      idOrFindOptions = {where: idOrFindOptions};
    }
Severity: Minor
Found in lib/classes/Service.js - About 1 hr to fix

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 findOrCreate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  findOrCreate: function(idOrFindOptions, queryOptions) {
    idOrFindOptions  = (typeof idOrFindOptions !== 'object') ? {where:{id: idOrFindOptions}} : idOrFindOptions;
    queryOptions = queryOptions || {};

    if (!queryOptions.where) {
Severity: Minor
Found in lib/classes/Service.js - About 1 hr to fix

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 modelDynamicFindersGenerator has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function modelDynamicFindersGenerator(model) {
  var finders    = ['findBy', 'findAllBy', 'countBy']
    , criteria   = [
      'is', 'in', 'like', 'notLike', 'iLike', 'notILike', 'startsWith', 'endsWith',
      'not', 'notEqual', 'between', 'notBetween', 'greaterThan', 'lessThan', 'greaterThanOrEqualTo', 'lessThanOrEqualTo',
Severity: Minor
Found in lib/utils/model/helpers/dynamicFinders.js - About 1 hr to fix
Severity
Category
Status
Source
Language