CleverStack/clever-orm

View on GitHub

Showing 47 of 72 total issues

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

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

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

            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

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

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

                        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

                        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 setRelationAccessor(accessor, alias, TargetModel, associatedObject, options) {
                          Severity: Minor
                          Found in utils/model/orm/associations/accessors/set.js - About 35 mins to fix

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

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