CleverStack/node-seed

View on GitHub

Showing 88 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      if (typeof idOrFindOptions === 'object' && this.model.type === 'ORM') {
        Object.keys(idOrFindOptions.where).forEach(function(name) {
          if (idOrFindOptions.where[ name ] === 'null') {
            idOrFindOptions.where[ name ] = null;
          }
Severity: Major
Found in lib/classes/Service.js and 1 other location - About 2 hrs to fix
lib/classes/Service.js on lines 99..105

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 92.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

      if (typeof idOrFindOptions === 'object' && this.model.type === 'ORM') {
        Object.keys(idOrFindOptions.where).forEach(function(name) {
          if (idOrFindOptions.where[ name ] === 'null') {
            idOrFindOptions.where[ name ] = null;
          }
Severity: Major
Found in lib/classes/Service.js and 1 other location - About 2 hrs to fix
lib/classes/Service.js on lines 167..173

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 92.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  modulesLoadedHook: function(module, callback) {
    if (module instanceof Module && typeof module.modulesLoaded === 'function') {
      module.debug('Module.modulesLoaded() hook...');

      module.on('ready', callback);
Severity: Major
Found in lib/classes/ModuleLoader.js and 1 other location - About 2 hrs to fix
lib/classes/ModuleLoader.js on lines 229..238

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 82.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  preResourcesHook: function(module, callback) {
    if (module instanceof Module && typeof module.preResources === 'function') {
      module.debug('Module.preResources() hook...');

      module.on('resourcesReady', callback);
Severity: Major
Found in lib/classes/ModuleLoader.js and 1 other location - About 2 hrs to fix
lib/classes/ModuleLoader.js on lines 252..261

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 82.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  FLOAT: function(length, decimals) {
    var field = {
      type: this.FLOAT,
      length: length,
      toString: function() {
Severity: Major
Found in lib/utils/model/helpers/types.js and 1 other location - About 2 hrs to fix
lib/utils/model/helpers/types.js on lines 55..69

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 76.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  DECIMAL: function(precision, scale) {
    var field = {
      type: this.DECIMAL,
      precision: precision,
      toString: function() {
Severity: Major
Found in lib/utils/model/helpers/types.js and 1 other location - About 2 hrs to fix
lib/utils/model/helpers/types.js on lines 40..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 76.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Similar blocks of code found in 5 locations. Consider refactoring.
Open

function InvalidData( message ) {
  Error.call( this );
  Error.captureStackTrace( this, this.constructor );

  this.name = this.constructor.name;
Severity: Major
Found in lib/exceptions/InvalidData.js and 4 other locations - About 1 hr to fix
lib/exceptions/DuplicateModel.js on lines 1..7
lib/exceptions/ModelNotFound.js on lines 1..7
lib/exceptions/ModelValidation.js on lines 1..7
lib/exceptions/ModuleDependencyNotMet.js on lines 1..7

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 66.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language