CleverStack/clever-orm

View on GitHub

Showing 72 of 72 total issues

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

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

            module.exports.afterLoad = function hydrateAfterEagerLoad(findOptions, model) {
              if (model !== null && findOptions.include && findOptions.include.length && model.entity.options.include) {
                var models = this.getDefinedModels();
            
                Object.keys(model.entity.options.includeMap).forEach(function(modelName) {
            Severity: Minor
            Found in utils/model/orm/associations/loaders/eager.js - About 1 hr to fix

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

                if (this.debug.enabled) {
                  this.debug(util.format('ormUtils.destroy(%s)', inspect(Object.keys(queryOptions).join(', '))));
                }
              Severity: Major
              Found in utils/model/orm/instance/destroy.js and 1 other location - About 1 hr to fix
              utils/model/orm/instance/save.js on lines 6..8

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

              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 (this.debug.enabled) {
                  this.debug(util.format('ormUtils.save(%s)', inspect(Object.keys(data).join(', '))));
                }
              Severity: Major
              Found in utils/model/orm/instance/save.js and 1 other location - About 1 hr to fix
              utils/model/orm/instance/destroy.js on lines 6..8

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

              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 findTargetModelsBeforeCreateSourceModel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports     = function findTargetModelsBeforeCreateSourceModel(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
              Severity: Minor
              Found in utils/model/orm/associations/nestedOperations/hasMany/beforeCreate.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

              Function updateTargetModelBeforeSourceModel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function updateTargetModelBeforeSourceModel(as, association, targetModel, values, queryOptions, callback) {
                var valueAs     = values[as]
                  , isSelfRef   = this === targetModel
                  , entity      = valueAs !== undefined && valueAs !== null ? valueAs.entity : undefined
                  , sourcePk    = this.primaryKey
              Severity: Minor
              Found in utils/model/orm/associations/nestedOperations/hasOne/beforeUpdate.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

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

              module.exports = function createTargetModelBeforeSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
              Severity: Major
              Found in utils/model/orm/associations/nestedOperations/hasOne/afterCreate.js - About 50 mins to fix

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

                module.exports = function aliasTargetModelAfterCreateSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
                Severity: Major
                Found in utils/model/orm/associations/nestedOperations/belongsTo/afterCreate.js - About 50 mins to fix

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

                  module.exports    = function createTargetModelsAfterSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
                  Severity: Major
                  Found in utils/model/orm/associations/nestedOperations/hasMany/afterCreate.js - About 50 mins to fix

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

                    module.exports = function aliasTargetModelAfterUpdateSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
                    Severity: Major
                    Found in utils/model/orm/associations/nestedOperations/belongsTo/afterUpdate.js - About 50 mins to fix

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

                            targetModel
                              .create(data, queryOptions)
                              .then(function(targetInstance) {
                                values[as] = targetInstance;
                      
                      
                      utils/model/orm/associations/nestedOperations/belongsTo/beforeUpdate.js on lines 20..26

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

                      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

                          targetModel
                            .find(nestedQuery, queryOptions)
                            .then(function(instance) {
                              values[as] = instance;
                              callback(null);
                      utils/model/orm/associations/nestedOperations/hasOne/afterCreate.js on lines 20..27

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

                      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 (this.debug.enabled) {
                          this.debug(util.format('ormUtils.findAll(%s)', inspect(underscore.clone(findOptions.where))));
                        }
                      Severity: Major
                      Found in utils/model/orm/findAll.js and 2 other locations - About 50 mins to fix
                      utils/model/orm/destroy.js on lines 8..10
                      utils/model/orm/find.js on lines 10..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 51.

                      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 (this.debug.enabled) {
                          this.debug(util.format('ormUtils.destroy(%s)', inspect(underscore.clone(queryOptions.where))));
                        }
                      Severity: Major
                      Found in utils/model/orm/destroy.js and 2 other locations - About 50 mins to fix
                      utils/model/orm/find.js on lines 10..12
                      utils/model/orm/findAll.js on lines 11..13

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

                      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 (this.debug.enabled) {
                          this.debug(util.format('ormUtils.find(%s)', inspect(underscore.clone(findOptions.where))));
                        }
                      Severity: Major
                      Found in utils/model/orm/find.js and 2 other locations - About 50 mins to fix
                      utils/model/orm/destroy.js on lines 8..10
                      utils/model/orm/findAll.js on lines 11..13

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

                      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