jmdobry/reheat

View on GitHub

Showing 296 of 296 total issues

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

        utils.forOwn(this.attributes, function (value, key) {
          if (utils.isObject(value) && value.constructor.__reheat_super__) {
            clone[key] = value.toJSON();
          } else if (utils.isArray(value) && value.length && utils.isObject(value[0]) && value[0].constructor.__reheat_super__) {
            clone[key] = [];
Severity: Major
Found in lib/model/prototype/index.js and 1 other location - About 1 day to fix
lib/model/prototype/index.js on lines 271..282

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

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

        utils.forOwn(this.attributes, function (value, key) {
          if (utils.isObject(value) && value.constructor.__reheat_super__) {
            clone[key] = value.clone();
          } else if (utils.isArray(value) && value.length && utils.isObject(value[0]) && value[0].constructor.__reheat_super__) {
            clone[key] = [];
Severity: Major
Found in lib/model/prototype/index.js and 1 other location - About 1 day to fix
lib/model/prototype/index.js on lines 124..135

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

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 205 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (container, Promise, utils, errors) {

  var errorPrefix = 'Collection.findAll(predicate[, options][, cb]): ';
  var IllegalArgumentError = errors.IllegalArgumentError;
  var RuntimeError = errors.RuntimeError;
Severity: Major
Found in lib/collection/static/findAll.js - About 1 day to fix

    File relations.test.js has 490 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*jshint loopfunc:true*/
    
    var Connection = require('../../../../build/instrument/lib/connection'),
        reheat = require('../../../../build/instrument/lib'),
        utils = require('../../../../build/instrument/lib/support/utils'),
    Severity: Minor
    Found in old_test/model/static/relations.test.js - About 7 hrs to fix

      File filter.test.js has 478 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*jshint loopfunc:true*/
      
      var filter = require('../../../../../build/instrument/lib/model/static/filter'),
          errors = require('../../../../../build/instrument/lib/support/errors'),
          support = require('../../../../support/support'),
      Severity: Minor
      Found in old_test/reheat/model/static/filter.test.js - About 7 hrs to fix

        Function exports has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (container, Promise, utils, errors) {
        
          var errorPrefix = 'Collection.findAll(predicate[, options][, cb]): ';
          var IllegalArgumentError = errors.IllegalArgumentError;
          var RuntimeError = errors.RuntimeError;
        Severity: Minor
        Found in lib/collection/static/findAll.js - About 7 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

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

                    if (support.TYPES_EXCEPT_OBJECT[i] && typeof support.TYPES_EXCEPT_OBJECT[i] !== 'function') {
                        queue.push((function (j) {
                            return instance.save(support.TYPES_EXCEPT_OBJECT[j]).then(function () {
                                support.fail('Should have failed on ' + support.TYPES_EXCEPT_OBJECT[j]);
                            })
        Severity: Major
        Found in old_test/reheat/model/prototype/save.test.js and 1 other location - About 7 hrs to fix
        old_test/reheat/model/prototype/clear.test.js on lines 72..85

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

        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

                for (var i = 0; i < support.TYPES_EXCEPT_STRING_OR_OBJECT.length; i++) {
                    queue.push((function (j) {
                        return Model.getAll('5', support.TYPES_EXCEPT_STRING_OR_OBJECT[j]).then(function () {
                            support.fail('Should have failed on ' + support.TYPES_EXCEPT_STRING_OR_OBJECT[j]);
                        })
        Severity: Major
        Found in old_test/reheat/model/static/getAll.test.js and 1 other location - About 7 hrs to fix
        old_test/reheat/model/static/get.test.js on lines 161..174

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

        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 (support.TYPES_EXCEPT_OBJECT[i] && support.TYPES_EXCEPT_OBJECT[i] !== true && typeof support.TYPES_EXCEPT_OBJECT[i] !== 'function') {
                        queue.push((function (j) {
                            return instance.clear(support.TYPES_EXCEPT_OBJECT[i]).then(function () {
                                support.fail('Should have failed on ' + support.TYPES_EXCEPT_OBJECT[j]);
                            })
        Severity: Major
        Found in old_test/reheat/model/prototype/clear.test.js and 1 other location - About 7 hrs to fix
        old_test/reheat/model/prototype/save.test.js on lines 290..303

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

        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 (support.TYPES_EXCEPT_OBJECT[i] && typeof support.TYPES_EXCEPT_OBJECT[i] !== 'function') {
                        queue.push((function (j) {
                            return Model.get('5', support.TYPES_EXCEPT_OBJECT[j]).then(function () {
                                support.fail('Should have failed on ' + support.TYPES_EXCEPT_OBJECT[j]);
                            })
        Severity: Major
        Found in old_test/reheat/model/static/get.test.js and 1 other location - About 7 hrs to fix
        old_test/reheat/model/static/getAll.test.js on lines 184..197

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

        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

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

            tearDown: function (cb) {
                connection.run(r.dbList())
                    .then(function (dbList) {
                        if (utils.contains(dbList, 'test')) {
                            return connection.run(r.dbDrop('test'));
        Severity: Major
        Found in old_test/model/static/relations.test.js and 1 other location - About 6 hrs to fix
        old_test/model/static/filter.relations.test.js on lines 105..122

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

        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

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

            tearDown: function (cb) {
                connection.run(r.dbList())
                    .then(function (dbList) {
                        if (utils.contains(dbList, 'test')) {
                            return connection.run(r.dbDrop('test'));
        Severity: Major
        Found in old_test/model/static/filter.relations.test.js and 1 other location - About 6 hrs to fix
        old_test/model/static/relations.test.js on lines 106..123

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

        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 relations has 154 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            relations: function (test) {
                var user = new User({
                        name: 'John Anderson'
                    }),
                    user2 = new User({
        Severity: Major
        Found in old_test/model/static/filter.relations.test.js - About 6 hrs to fix

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

                  if (!utils.isString(primaryKey)) {
                    throw new errors.IllegalArgumentError(errorPrefix + 'primaryKey: Must be a string!', { actual: typeof primaryKey, expected: 'string' });
                  } else if (!utils.isObject(options)) {
                    throw new errors.IllegalArgumentError(errorPrefix + 'options: Must be an object!', { actual: typeof options, expected: 'object' });
                  } else if (options.with && !utils.isArray(options.with)) {
          Severity: Major
          Found in lib/model/static/findOne.js and 1 other location - About 6 hrs to fix
          lib/model/static/destroyOne.js on lines 74..80

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

          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

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

                  if (!utils.isString(primaryKey)) {
                    throw new errors.IllegalArgumentError(errorPrefix + 'primaryKey: Must be a string!', { actual: typeof primaryKey, expected: 'string' });
                  } else if (!utils.isObject(options)) {
                    throw new errors.IllegalArgumentError(errorPrefix + 'options: Must be an object!', { actual: typeof options, expected: 'object' });
                  } else if (options.with && !utils.isArray(options.with)) {
          Severity: Major
          Found in lib/model/static/destroyOne.js and 1 other location - About 6 hrs to fix
          lib/model/static/findOne.js on lines 93..99

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

          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 _findAll has 147 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function _findAll(predicate, options) {
              var Collection = this;
              var models = container.get('models');
              var Model;
          
          
          Severity: Major
          Found in lib/collection/static/findAll.js - About 5 hrs to fix

            Function exports has 146 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function (container, Promise, utils, errors) {
              var errorPrefix = 'Collection.getAll(keys, index[, options][, cb]): ';
              var IllegalArgumentError = errors.IllegalArgumentError;
              var RuntimeError = errors.RuntimeError;
            
            
            Severity: Major
            Found in lib/collection/static/getAll.js - About 5 hrs to fix

              Function exports has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function (utils, errors) {
                var IllegalArgumentError = errors.IllegalArgumentError,
                  ValidationError = errors.ValidationError,
                  UnhandledError = errors.UnhandledError;
              
              
              Severity: Minor
              Found in lib/model/prototype/setSync.js - About 5 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 exports has 140 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function (Promise, utils, errors, models) {
                /**
                 * @doc method
                 * @id Model.instance_methods:save
                 * @name save
              Severity: Major
              Found in lib/model/prototype/save.js - About 5 hrs to fix

                Function getAll has 140 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function getAll(keys, index, options, cb) {
                    var Collection = this;
                    var models = container.get('models');
                    var Model;
                
                
                Severity: Major
                Found in lib/collection/static/getAll.js - About 5 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language