CleverStack/clever-orm

View on GitHub

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

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

      bigIntType: function(options) {
        var field = !!options.length ? Sequelize.BIGINT(options.length) : Sequelize.BIGINT;
        if (!!options.unsigned && !!options.zerofill) {
          field = field.UNSIGNED.ZEROFILL;
        } else if (!!options.unsigned && !options.zerofill) {
    Severity: Major
    Found in module.js and 1 other location - About 6 hrs to fix
    module.js on lines 285..295

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

    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

      numberType: function(options) {
        var field = !!options.length ? Sequelize.INTEGER(options.length) : Sequelize.INTEGER;
        if (!!options.unsigned && !!options.zerofill) {
          field = field.UNSIGNED.ZEROFILL;
        } else if (!!options.unsigned && !options.zerofill) {
    Severity: Major
    Found in module.js and 1 other location - About 6 hrs to fix
    module.js on lines 309..319

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

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

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

          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
            , doubleLinked = association.doubleLinked;
        utils/model/orm/associations/nestedOperations/hasMany/beforeUpdate.js on lines 13..17

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

        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 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
            , doubleLinked = association.doubleLinked;
        utils/model/orm/associations/nestedOperations/hasMany/beforeCreate.js on lines 17..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 93.

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

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

                if (!!options.scale) {
                  field = Sequelize.DECIMAL(options.precision, options.scale);
                } else if (!!options.precision) {
                  field = Sequelize.DECIMAL(options.precision);
                }
            Severity: Major
            Found in module.js and 1 other location - About 1 hr to fix
            module.js on lines 323..327

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

            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 (!!options.decimals) {
                  field = Sequelize.FLOAT(options.length, options.decimals);
                } else if (!!options.length) {
                  field = Sequelize.FLOAT(options.length);
                }
            Severity: Major
            Found in module.js and 1 other location - About 1 hr to fix
            module.js on lines 341..345

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

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

                    Severity
                    Category
                    Status
                    Source
                    Language