CleverStack/node-seed

View on GitHub

Showing 88 of 88 total issues

Function exports has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

module.exports = function afterExtendModel(utils, defineProp, model, Klass, modelName, debug) {
Severity: Minor
Found in lib/utils/model/helpers/afterExtend.js - About 45 mins to fix

Function setupNestedOperations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function setupNestedOperations(Klass, modelName, model, debug) {
  injector.getInstance('moduleLoader').on('routesInitialized', function() {
    debug( 'Parsing templated event handlers...' );
    Object.keys( Klass ).forEach( function( propName ) {
      if ( propName.indexOf( ' ' ) !== -1 || utils.model.helpers.eventNames.indexOf( propName ) !== -1 ) {
Severity: Minor
Found in lib/utils/model/helpers/nestedOperations.js - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                if (dottie.get(loaded, fullPath) === undefined) {
                  if (debug.enabled) {
                    debug('Loading %s into magic module from %s...', fullPath, actualPath);
                  }

Severity: Major
Found in lib/utils/magicModule.js - About 45 mins to fix

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

  if (modules.indexOf('clever-orm') !== -1 && config['clever-orm'] !== undefined) {
    config['clever-orm'].modelAssociations = modelAssociations;
  }
Severity: Minor
Found in lib/config/index.js and 1 other location - About 40 mins to fix
lib/config/index.js on lines 72..74

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 48.

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

  if (modules.indexOf('clever-odm') !== -1 && config['clever-odm'] !== undefined) {
    config['clever-odm'].modelAssociations = modelAssociations;
  }
Severity: Minor
Found in lib/config/index.js and 1 other location - About 40 mins to fix
lib/config/index.js on lines 68..70

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 48.

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 exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

module.exports = function defineModelFields(Klass, Proto, modelName, modelType, debug) {
Severity: Minor
Found in lib/utils/model/helpers/defineFields.js - About 35 mins to fix

Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

module.exports  = function emitAfterEvent(eventName, modelDataOrFindOptions, queryOptions, model, callback) {
Severity: Minor
Found in lib/utils/model/helpers/events/afterEvent.js - About 35 mins to fix

Function runValidatorForField has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  runValidatorForField: function(fieldName, value, validators, validatorName, callback) {
Severity: Minor
Found in lib/classes/Validator.js - About 35 mins to fix

Function extend has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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 getAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  getAction: function() {
    var service     = this.Class.service !== null ? this.Class.service : false
      , model       = service && service.model !== undefined ? service.model : false
      , findOptions;

Severity: Minor
Found in lib/classes/Controller.js - About 35 mins 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 deleteAction has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  deleteAction: function() {
    var service     = this.Class.service !== null ? this.Class.service : false
      , model       = service && service.model !== undefined ? service.model : false
      , findOptions;

Severity: Minor
Found in lib/classes/Controller.js - About 35 mins 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

  TINYINT: function(length) {
    return {
      type: this.TINYINT,
      length: length,
      toString: function() {
Severity: Minor
Found in lib/utils/model/helpers/types.js and 1 other location - About 35 mins to fix
lib/utils/model/helpers/types.js on lines 31..39

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 46.

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

  BIGINT: function(length) {
    return {
      type: this.BIGINT,
      length: length,
      toString: function() {
Severity: Minor
Found in lib/utils/model/helpers/types.js and 1 other location - About 35 mins to fix
lib/utils/model/helpers/types.js on lines 22..30

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 46.

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 5 locations. Consider refactoring.
Open

      if (!this.model) {
        reject('Model not found, either set ' + this._name + '.model or implement ' + this._name + '.find()');
        return;
      }
Severity: Major
Found in lib/classes/Service.js and 4 other locations - About 30 mins to fix
lib/classes/Service.js on lines 132..135
lib/classes/Service.js on lines 162..165
lib/classes/Service.js on lines 192..195
lib/classes/Service.js on lines 271..274

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 45.

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 5 locations. Consider refactoring.
Open

      if (!this.model) {
        reject('Model not found, either set ' + this._name + '.model or implement ' + this._name + '.find()');
        return;
      }
Severity: Major
Found in lib/classes/Service.js and 4 other locations - About 30 mins to fix
lib/classes/Service.js on lines 94..97
lib/classes/Service.js on lines 132..135
lib/classes/Service.js on lines 162..165
lib/classes/Service.js on lines 271..274

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 45.

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 5 locations. Consider refactoring.
Open

      if (!this.model) {
        reject('Model not found, either set ' + this._name + '.model or implement ' + this._name + '.find()');
        return;
      }
Severity: Major
Found in lib/classes/Service.js and 4 other locations - About 30 mins to fix
lib/classes/Service.js on lines 94..97
lib/classes/Service.js on lines 132..135
lib/classes/Service.js on lines 192..195
lib/classes/Service.js on lines 271..274

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 45.

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 3 locations. Consider refactoring.
Open

    if (Klass.updatedAt !== 'updatedAt') {
      Klass.aliases.push({
        fieldName   : 'updatedAt',
        columnName  : Klass.updatedAt
      });
Severity: Minor
Found in lib/utils/model/behaviours/timeStampable.js and 2 other locations - About 30 mins to fix
lib/utils/model/behaviours/softDeleteable.js on lines 7..12
lib/utils/model/behaviours/timeStampable.js on lines 7..12

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 45.

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 5 locations. Consider refactoring.
Open

      if (!this.model) {
        reject('Model not found, either set ' + this._name + '.model or implement ' + this._name + '.find()');
        return;
      }
Severity: Major
Found in lib/classes/Service.js and 4 other locations - About 30 mins to fix
lib/classes/Service.js on lines 94..97
lib/classes/Service.js on lines 162..165
lib/classes/Service.js on lines 192..195
lib/classes/Service.js on lines 271..274

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 45.

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

validator.extend('min', function(str, val) {
  var number = parseFloat(str);
  return isNaN(number) || number >= val;
});
Severity: Minor
Found in lib/classes/Validator.js and 1 other location - About 30 mins to fix
lib/classes/Validator.js on lines 53..56

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 45.

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

validator.extend('max', function(str, val) {
  var number = parseFloat(str);
  return isNaN(number) || number <= val;
});
Severity: Minor
Found in lib/classes/Validator.js and 1 other location - About 30 mins to fix
lib/classes/Validator.js on lines 48..51

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 45.

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