CleverStack/clever-orm

View on GitHub

Showing 47 of 72 total issues

Function exports has 165 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
  var defaultConfig = require(path.join(__dirname, 'config', 'default.json'))
    , configFile    = null
    , config        = {}
    , dbTarget      = grunt.option('module') || null
Severity: Major
Found in Gruntfile.js - About 6 hrs to fix

    Function defineAssociations has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    function defineAssociations(models) {
      /*jshint validthis: true */
      var cleverOrm  = this
        , modelNames = Object.keys(models);
    
    
    Severity: Minor
    Found in utils/model/orm/associations/define.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 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', '')]
    Severity: Major
    Found in bin/seedModels.js - About 3 hrs to fix

      Function createTargetModelsAfterSourceModel has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports    = function createTargetModelsAfterSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
        var valuesAs    = values[as]
          , isSelfRef   = this === targetModel
          , entity      = valuesAs !== undefined && valuesAs !== null ? valuesAs.entity : undefined
          , sourcePk    = this.primaryKey
      Severity: Minor
      Found in utils/model/orm/associations/nestedOperations/hasMany/afterCreate.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 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 !== 'ORM') {
      Severity: Major
      Found in bin/seedModels.js - About 3 hrs to fix

        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 });
        Severity: Major
        Found in bin/seedModels.js - About 2 hrs to fix

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

          module.exports.load = function eagerLoad(findOptions) {
            if (!!findOptions.include && findOptions.include instanceof Array) {
              for(var i = 0; i < findOptions.include.length; i++) {
                if (this.debug.enabled) {
                  this.debug('eagerLoad(' + inspect(underscore.omit(findOptions.include[i], 'model', 'include')) + ', ' + inspect(findOptions.include[i].model.name) + ')');
          Severity: Minor
          Found in utils/model/orm/associations/loaders/eager.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

          File module.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var injector   = require('injector')
            , Sequelize  = require('sequelize')
            , debug      = require('debug')
            , utils      = require('utils')
            , Module     = injector.getInstance('Module')
          Severity: Minor
          Found in module.js - About 2 hrs to fix

            Function getFieldType has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              getFieldType: function(Static, options, name) {
                var field;
            
                switch(options.type.type || options.type) {
            
            
            Severity: Minor
            Found in module.js - About 1 hr to fix

              Function exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function(grunt) {
                var defaultConfig = require(path.join(__dirname, 'config', 'default.json'))
                  , configFile    = null
                  , config        = {}
                  , dbTarget      = grunt.option('module') || null
              Severity: Minor
              Found in Gruntfile.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 createTargetModelsAfterSourceModel has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports    = function createTargetModelsAfterSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
                var valuesAs    = values[as]
                  , isSelfRef   = this === targetModel
                  , entity      = valuesAs !== undefined && valuesAs !== null ? valuesAs.entity : undefined
                  , sourcePk    = this.primaryKey

                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', '')]
                Severity: Minor
                Found in bin/seedModels.js - About 1 hr to fix

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

                  function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {
                    var accessors   = accessorTypes[assocType]
                      , singular    = inflect.singularize(alias)
                      , plural      = inflect.pluralize(alias);
                  
                  
                  Severity: Minor
                  Found in utils/model/orm/associations/accessors/define.js - About 1 hr to fix

                    Function defineNestedOperations has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function defineNestedOperations(sourceModel, assocType, targetModel, alias, association) {
                      /*jshint validthis: true */
                      var events   = this[assocType]
                        , eventNames;
                    
                    
                    Severity: Minor
                    Found in utils/model/orm/associations/nestedOperations/define.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 defineField has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      defineField: function(Static, fields, name) {
                        var fieldDefinition = {}
                          , columnName      = name
                          , options         = Static.fields[name];
                    
                    
                    Severity: Minor
                    Found in module.js - About 1 hr to fix

                      Function defineAssociations has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function defineAssociations(models) {
                        /*jshint validthis: true */
                        var cleverOrm  = this
                          , modelNames = Object.keys(models);
                      
                      
                      Severity: Minor
                      Found in utils/model/orm/associations/define.js - About 1 hr to fix

                        Function setupOptions has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          setupOptions: function(parseDebug, sequelizeConf, Static) {
                            parseDebug('Setup options...');
                        
                            if (Static.dbName !== false ) {
                              parseDebug('Setting dbName=' + Static.dbName + ' (sequelize tableName option)...');
                        Severity: Minor
                        Found in module.js - About 1 hr to fix

                          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 !== 'ORM') {
                          Severity: Minor
                          Found in bin/seedModels.js - About 1 hr to fix

                            Function eachSourceModel has 28 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];
                            Severity: Minor
                            Found in utils/model/orm/associations/define.js - About 1 hr to fix

                              Function findTargetModelsBeforeUpdateSourceModel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              module.exports = function findTargetModelsBeforeUpdateSourceModel(as, association, targetModel, values, queryOptions, callback) {
                                var valuesAs     = values[as] ? (values[as] instanceof Array ? underscore.clone(values[as]) : [underscore.clone(values[as])]) : false
                                  , isSelfRef    = this === targetModel
                                  , sourcePk     = this.primaryKey
                                  , targetPK     = targetModel.primaryKey

                              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