CleverStack/clever-odm

View on GitHub

Showing 28 of 53 total issues

Function exports has 94 lines of code (exceeds 25 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: Major
Found in Gruntfile.js - About 3 hrs to fix

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

    function defineAssociations(models) {
      /*jshint validthis: true */
      var cleverOdm  = this
        , modelNames = Object.keys(models);
    
    
    Severity: Minor
    Found in lib/model/associations/index.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 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 !== 'ODM') {
      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 defineField has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            defineField: function(Klass, fields, mongooseConf, name) {
              var fieldDefinition = {}
                , columnName      = name
                , options         = Klass.fields[name];
          
          
          Severity: Minor
          Found in module.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 defineField has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            defineField: function(Klass, fields, mongooseConf, name) {
              var fieldDefinition = {}
                , columnName      = name
                , options         = Klass.fields[name];
          
          
          Severity: Major
          Found in module.js - About 2 hrs to fix

            Function belongsTo has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function belongsTo(mongoose, Klass, Proto, assocTo) {
              assocTo      = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
            
              if (Klass.primaryKeys.length !== 1) {
                throw new Error('belongsTo association not support without primaryKeys.');
            Severity: Minor
            Found in lib/model/associations/belongsTo.js - About 2 hrs to fix

              Function hasMany has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function hasMany(mongoose, Klass, Proto, assocTo) {
                assocTo      = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
              
                if (Klass.primaryKeys.length !== 1) {
                  throw new Error('hasMany association not support without primaryKeys.');
              Severity: Minor
              Found in lib/model/associations/hasMany.js - About 1 hr to fix

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

                  function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {
                    console.dir(arguments);
                    process.exit(1);
                    var accessors   = this[assocType]
                      , singular    = inflect.singularize(alias)
                  Severity: Minor
                  Found in lib/model/associations/accessors/index.js - About 1 hr to fix

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

                    module.exports = function belongsTo(mongoose, Klass, Proto, assocTo) {
                      assocTo      = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
                    
                      if (Klass.primaryKeys.length !== 1) {
                        throw new Error('belongsTo association not support without primaryKeys.');
                    Severity: Minor
                    Found in lib/model/associations/belongsTo.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 hasOne has 38 lines of code (exceeds 25 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 1 hr to fix

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

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

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

                        module.exports = function hasMany(mongoose, Klass, Proto, assocTo) {
                          assocTo      = assocTo instanceof Array ? underscore.clone(assocTo) : [assocTo, {}];
                        
                          if (Klass.primaryKeys.length !== 1) {
                            throw new Error('hasMany association not support without primaryKeys.');
                        Severity: Minor
                        Found in lib/model/associations/hasMany.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 getFieldType has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

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

                            parseModelSchema: function(Klass, Proto) {
                              var parseDebug = this.proxy(function(msg) {
                                    this.debug(Klass.modelName + 'Model: ' + msg);
                                  })
                                , mongooseConf = {}
                          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 !== 'ODM') {
                            Severity: Minor
                            Found in bin/seedModels.js - About 1 hr to fix

                              Function eachSourceModel has 30 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 lib/model/associations/index.js - About 1 hr to fix

                                Function eachAssociationType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    associationTypes.forEach(function eachAssociationType(assocType) {
                                      var targets = models[sourceModelName][assocType];
                                
                                      if (!(targets instanceof Array)) {
                                        targets = [targets];
                                Severity: Minor
                                Found in lib/model/associations/index.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language