CleverStack/clever-odm

View on GitHub

Showing 53 of 53 total issues

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

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

          Klass.setters[association.identifier] = function setRelationIdentifier(val) {
            this.entity[association.as] = val.id || val;
        
            return this;
          };
        Severity: Major
        Found in lib/model/associations/belongsTo.js and 1 other location - About 1 hr to fix
        lib/model/associations/hasMany.js on lines 44..47

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

        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

          Klass.setters[association.identifier] = function setRelationIdentifier(val) {
            this.entity[association.identifier] = val.id || val;
            return this;
          };
        Severity: Major
        Found in lib/model/associations/hasMany.js and 1 other location - About 1 hr to fix
        lib/model/associations/belongsTo.js on lines 46..50

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

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

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

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

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

            if (this.debug.enabled) {
              this.debug(util.format('odmUtils.destroy(%s)', inspect(Object.keys(queryOptions).join(', '))));
            }
          Severity: Major
          Found in lib/model/instance/destroy.js and 1 other location - About 1 hr to fix
          lib/model/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

          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

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

            association.as          = inflect.singularize(inflect.camelize((associationOptions.alias || associationOptions.as || targetModelName.replace('Model','')), true))
          Severity: Minor
          Found in lib/model/associations/belongsTo.js and 1 other location - About 55 mins to fix
          lib/model/associations/hasMany.js on lines 21..21

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

          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

            association.as          = inflect.pluralize(inflect.camelize((associationOptions.alias || associationOptions.as || targetModelName.replace('Model','')), true))
          Severity: Minor
          Found in lib/model/associations/hasMany.js and 1 other location - About 55 mins to fix
          lib/model/associations/belongsTo.js on lines 21..21

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

          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('odmUtils.find(%s)', inspect(underscore.clone(findOptions.where))));
            }
          Severity: Major
          Found in lib/model/find.js and 2 other locations - About 50 mins to fix
          lib/model/destroy.js on lines 9..11
          lib/model/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('odmUtils.findAll(%s)', inspect(underscore.clone(findOptions.where))));
            }
          Severity: Major
          Found in lib/model/findAll.js and 2 other locations - About 50 mins to fix
          lib/model/destroy.js on lines 9..11
          lib/model/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('odmUtils.destroy(%s)', inspect(underscore.clone(queryOptions.where))));
            }
          Severity: Major
          Found in lib/model/destroy.js and 2 other locations - About 50 mins to fix
          lib/model/find.js on lines 10..12
          lib/model/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 2 locations. Consider refactoring.
          Open

            var find     = this.entity.find(findOptions.where, findOptions.attributes, queryOptions)
              , populate = eager.load.apply(this, [findOptions, queryOptions]);
          Severity: Minor
          Found in lib/model/findAll.js and 1 other location - About 45 mins to fix
          lib/model/find.js on lines 14..15

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

          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

          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

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

              var findOne  = this.entity.findOne(findOptions.where, findOptions.attributes, queryOptions)
                , populate = eager.load.apply(this, [findOptions, queryOptions]);
            Severity: Minor
            Found in lib/model/find.js and 1 other location - About 45 mins to fix
            lib/model/findAll.js on lines 15..16

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

            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

            moduleLdr.loadModules(process.argv && process.argv[2] !== 'null' ? ['clever-orm', process.argv[2]] : false);
            Severity: Minor
            Found in bin/rebase.js and 1 other location - About 45 mins to fix
            bin/seedModels.js on lines 190..190

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

            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

            moduleLdr.loadModules(process.argv && process.argv[2] !== 'null' ? ['clever-odm', process.argv[2]] : false);
            Severity: Minor
            Found in bin/seedModels.js and 1 other location - About 45 mins to fix
            bin/rebase.js on lines 47..47

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

            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 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
              Severity
              Category
              Status
              Source
              Language