CleverStack/clever-odm

View on GitHub

Showing 28 of 53 total issues

Function exports has a Cognitive Complexity of 9 (exceeds 5 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          = {};
Severity: Minor
Found in Gruntfile.js - About 55 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 (!(model.entity[as][i] instanceof CsModel)) {
              model.entity[as][i] = new CsModel(model.entity[as][i]);
            }
Severity: Major
Found in lib/model/associations/loaders/eager.js - About 45 mins to fix

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

    function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {
    Severity: Minor
    Found in lib/model/associations/accessors/index.js - About 35 mins to fix

      Function associateModels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        associateModels: function(Klass, Proto, assocType, assocTo) {
          var modelName   = Klass.modelName
            , models      = require('models');
      
          if (Klass.type.toLowerCase() === 'odm') {
      Severity: Minor
      Found in 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 hasOne has a Cognitive Complexity of 7 (exceeds 5 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()
      Severity: Minor
      Found in lib/model/associations/hasOne.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 eagerLoad has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.load = function eagerLoad(findOptions) {
        var populate = []
          , addToPopulate = function(modelInclude, index, array, parentInclude) {
              var include = modelInclude.model.modelName || modelInclude.modelName;
      
      
      Severity: Minor
      Found in lib/model/associations/loaders/eager.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 preSetup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        preSetup: function() {
          var dbConfig     = this.config.mongoose
            , queryLogger  = debug('cleverstack:queryLog');
      
          if (!!dbConfig.debug || queryLogger.enabled) {
      Severity: Minor
      Found in module.js - About 25 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 hydrateModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function hydrateModel(findOptions, model, callback) {
        var ModelClass = this;
      
        if (model !== null) {
          model = new ModelClass(model);
      Severity: Minor
      Found in lib/model/instance/hydrator.js - About 25 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

      Severity
      Category
      Status
      Source
      Language