CleverStack/clever-orm

View on GitHub

Showing 47 of 72 total issues

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

function defineNestedOperations(sourceModel, assocType, targetModel, alias, association) {
Severity: Minor
Found in utils/model/orm/associations/nestedOperations/define.js - About 35 mins to fix

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

    function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {
    Severity: Minor
    Found in utils/model/orm/associations/accessors/define.js - About 35 mins to fix

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

      module.exports = function defaultRelationAccessor(accessor,  alias, TargetModel, argOne, argTwo) {
      Severity: Minor
      Found in utils/model/orm/associations/accessors/default.js - About 35 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

          Function findTargetModelBeforeCreateSourceModel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function findTargetModelBeforeCreateSourceModel(as, association, targetModel, values, queryOptions, callback) {
            try {
              if (values[as] !== undefined && values[as] !== null && values[as].entity === undefined && (typeof values[as] !== 'object' || values[as][targetModel.primaryKey[0]] === undefined)) {
                targetModel
                  .find(typeof values[as] === 'object' ? underscore.clone(values[as]) : { where: { id: values[as] } }, queryOptions)
          Severity: Minor
          Found in utils/model/orm/associations/nestedOperations/belongsTo/beforeCreate.js - About 35 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 createTargetModelBeforeSourceModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function createTargetModelBeforeSourceModel(as, association, targetModel, instance, values, queryOptions, callback) {
            try {
              if (values[as] !== undefined && values[as] !== null && values[as].entity === undefined && typeof values[as] === 'object') {
                var data = underscore.extend(
                  typeof values[as] === 'object' ? underscore.clone(values[as]) : { id: values[as] }
          Severity: Minor
          Found in utils/model/orm/associations/nestedOperations/hasOne/afterCreate.js - About 25 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 hydrateModel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function hydrateModel(findOptions, model, callback) {
            var ModelClass = this;
          
            if (model !== null) {
              model = new ModelClass(model);
          Severity: Minor
          Found in utils/model/orm/instance/hydrator.js - About 25 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

          Severity
          Category
          Status
          Source
          Language