CleverStack/clever-orm

View on GitHub

Showing 72 of 72 total issues

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

module.exports = function findTargetModelBeforeCreateSourceModel(as, association, targetModel, values, queryOptions, callback) {
Severity: Minor
Found in utils/model/orm/associations/nestedOperations/belongsTo/beforeCreate.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (!(model.entity[as][i] instanceof CsModel)) {
                  model.entity[as][i] = new CsModel(model.entity[as][i]);
                  hydrateAfterEagerLoad.apply(CsModel, [model.entity[as][i].entity.options, model.entity[as][i]]);
                }
    Severity: Major
    Found in utils/model/orm/associations/loaders/eager.js - About 45 mins to fix

      Function getFieldType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        getFieldType: function(Static, options, name) {
          var field;
      
          switch(options.type.type || options.type) {
      
      
      Severity: Minor
      Found in module.js - About 45 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 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      module.exports     = function findTargetModelsBeforeCreateSourceModel(as, association, targetModel, values, queryOptions, callback) {
      Severity: Minor
      Found in utils/model/orm/associations/nestedOperations/hasMany/beforeCreate.js - About 45 mins to fix

        Function defineField has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          defineField: function(Static, fields, name) {
            var fieldDefinition = {}
              , columnName      = name
              , options         = Static.fields[name];
        
        
        Severity: Minor
        Found in module.js - About 45 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 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        module.exports = function findTargetModelsBeforeUpdateSourceModel(as, association, targetModel, values, queryOptions, callback) {
        Severity: Minor
        Found in utils/model/orm/associations/nestedOperations/hasMany/beforeUpdate.js - About 45 mins to fix

          Identical 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/seedModels.js and 1 other location - About 45 mins to fix
          bin/rebase.js on lines 66..66

          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 exports has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          module.exports = function findTargetModelBeforeUpdateSourceModel(as, association, targetModel, values, queryOptions, callback) {
          Severity: Minor
          Found in utils/model/orm/associations/nestedOperations/belongsTo/beforeUpdate.js - About 45 mins to fix

            Function findTargetModelBeforeUpdateSourceModel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function findTargetModelBeforeUpdateSourceModel(as, association, targetModel, values, queryOptions, callback) {
              var valueAs     = values[as]
                , entity      = valueAs !== undefined && valueAs !== null ? valueAs.entity : undefined
                , isTargetPk  = valueAs ? !isNaN(valueAs) : false
                , targetPK    = targetModel.primaryKey
            Severity: Minor
            Found in utils/model/orm/associations/nestedOperations/belongsTo/beforeUpdate.js - About 45 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

            Identical 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 192..192

            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 exports has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            module.exports = function updateTargetModelBeforeSourceModel(as, association, targetModel, values, queryOptions, callback) {
            Severity: Minor
            Found in utils/model/orm/associations/nestedOperations/hasOne/beforeUpdate.js - About 45 mins to fix

              Function setupOptions has a Cognitive Complexity of 8 (exceeds 5 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 45 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 6 locations. Consider refactoring.
              Open

                  if (Static.charset !== false ) {
                    parseDebug('Setting charset=' + Static.charset + '...');
                    sequelizeConf.charset = Static.charset;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 114..117
              module.js on lines 119..122
              module.js on lines 129..132
              module.js on lines 139..142
              module.js on lines 144..147

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

              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 6 locations. Consider refactoring.
              Open

                  if (Static.collate !== false ) {
                    parseDebug('Setting collate=' + Static.collate + '...');
                    sequelizeConf.collate = Static.collate;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 114..117
              module.js on lines 119..122
              module.js on lines 129..132
              module.js on lines 134..137
              module.js on lines 139..142

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

              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 6 locations. Consider refactoring.
              Open

                  if (Static.comment !== false ) {
                    parseDebug('Setting comment=' + Static.comment + '...');
                    sequelizeConf.comment = Static.comment;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 114..117
              module.js on lines 119..122
              module.js on lines 129..132
              module.js on lines 134..137
              module.js on lines 144..147

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

              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 6 locations. Consider refactoring.
              Open

                  if (Static.dbName !== false ) {
                    parseDebug('Setting dbName=' + Static.dbName + ' (sequelize tableName option)...');
                    sequelizeConf.tableName = Static.dbName;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 119..122
              module.js on lines 129..132
              module.js on lines 134..137
              module.js on lines 139..142
              module.js on lines 144..147

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

              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 6 locations. Consider refactoring.
              Open

                  if (Static.freezeDbName !== false) {
                    parseDebug('Setting freezeDbName=' + Static.freezeDbName + ' (sequelize freezeTableName option)...');
                    sequelizeConf.freezeTableName = Static.freezeDbName;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 114..117
              module.js on lines 129..132
              module.js on lines 134..137
              module.js on lines 139..142
              module.js on lines 144..147

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

              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 6 locations. Consider refactoring.
              Open

                  if (Static.engine !== false) {
                    parseDebug('Setting engine=' + Static.engine + '...');
                    sequelizeConf.engine = Static.engine;
                  }
              Severity: Major
              Found in module.js and 5 other locations - About 40 mins to fix
              module.js on lines 114..117
              module.js on lines 119..122
              module.js on lines 134..137
              module.js on lines 139..142
              module.js on lines 144..147

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

              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

              Consider simplifying this complex logical expression.
              Open

                if (!isSelfRef && !!doubleLinked && !!valuesAs && valuesAs.length &&
                    (typeof valuesAs[0] !== 'object' || valuesAs[0][targetPK] === undefined)) {
              
                  targetModel
                    .findAll(nestedQuery, queryOptions)
              Severity: Major
              Found in utils/model/orm/associations/nestedOperations/hasMany/beforeUpdate.js - About 40 mins to fix

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

                module.exports = function createRelationAccessor(accessor, alias, TargetModel, values, options) {
                Severity: Minor
                Found in utils/model/orm/associations/accessors/create.js - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language