CleverStack/clever-orm

View on GitHub

Showing 72 of 72 total issues

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

    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

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

              if (this.debug.enabled) {
                this.debug(util.format('ormUtils.update(%s)', inspect(underscore.clone(data))));
              }
            Severity: Minor
            Found in utils/model/orm/update.js and 1 other location - About 35 mins to fix
            utils/model/orm/create.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 47.

            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('ormUtils.create(%s)', inspect(underscore.clone(modelData))));
              }
            Severity: Minor
            Found in utils/model/orm/create.js and 1 other location - About 35 mins to fix
            utils/model/orm/update.js on lines 15..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 47.

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

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

              sourceModel.setters[association.as] = function setRelation(val) {
                this.entity[association.as] = val;
              };
            Severity: Minor
            Found in utils/model/orm/associations/accessors/define.js and 1 other location - About 35 mins to fix
            utils/model/orm/associations/accessors/define.js on lines 46..48

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

            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

              sourceModel.setters[association.identifier] = function setRelationIdentifer(val) {
                this.entity[association.identifier] = val;
              };
            Severity: Minor
            Found in utils/model/orm/associations/accessors/define.js and 1 other location - About 35 mins to fix
            utils/model/orm/associations/accessors/define.js on lines 49..51

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

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