sequelize/sequelize

View on GitHub
src/associations/belongs-to-many.js

Summary

Maintainability
F
1 wk
Test Coverage

File belongs-to-many.js has 594 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const Utils = require('./../utils');
const Helpers = require('./helpers');
const _ = require('lodash');
const Association = require('./base');
const BelongsTo = require('./belongs-to');
Severity: Major
Found in src/associations/belongs-to-many.js - About 1 day to fix

    Function constructor has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(source, target, options) {
        super(source, target, options);
    
        if (this.options.through === undefined || this.options.through === true || this.options.through === null) {
          throw new AssociationError(
    Severity: Minor
    Found in src/associations/belongs-to-many.js - About 6 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 constructor has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(source, target, options) {
        super(source, target, options);
    
        if (this.options.through === undefined || this.options.through === true || this.options.through === null) {
          throw new AssociationError(
    Severity: Major
    Found in src/associations/belongs-to-many.js - About 5 hrs to fix

      Function _injectAttributes has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _injectAttributes() {
          this.identifier = this.foreignKey;
          this.foreignIdentifier = this.otherKey;
      
          // remove any PKs previously defined by sequelize
      Severity: Major
      Found in src/associations/belongs-to-many.js - About 4 hrs to fix

        Function set has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async set(sourceInstance, newAssociatedObjects, options) {
            options = options || {};
        
            const sourceKey = this.sourceKey;
            const targetKey = this.targetKey;
        Severity: Major
        Found in src/associations/belongs-to-many.js - About 3 hrs to fix

          Function set has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            async set(sourceInstance, newAssociatedObjects, options) {
              options = options || {};
          
              const sourceKey = this.sourceKey;
              const targetKey = this.targetKey;
          Severity: Minor
          Found in src/associations/belongs-to-many.js - About 3 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 _injectAttributes has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            _injectAttributes() {
              this.identifier = this.foreignKey;
              this.foreignIdentifier = this.otherKey;
          
              // remove any PKs previously defined by sequelize
          Severity: Minor
          Found in src/associations/belongs-to-many.js - About 3 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 add has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async add(sourceInstance, newInstances, options) {
              // If newInstances is null or undefined, no-op
              if (!newInstances) return Promise.resolve();
          
              options = { ...options };
          Severity: Major
          Found in src/associations/belongs-to-many.js - About 3 hrs to fix

            Function add has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

              async add(sourceInstance, newInstances, options) {
                // If newInstances is null or undefined, no-op
                if (!newInstances) return Promise.resolve();
            
                options = { ...options };
            Severity: Minor
            Found in src/associations/belongs-to-many.js - About 3 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 updateAssociations has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const updateAssociations = currentRows => {
                  const obsoleteAssociations = [];
                  const promises = [];
                  const defaultAttributes = options.through || {};
            
            
            Severity: Major
            Found in src/associations/belongs-to-many.js - About 2 hrs to fix

              Function updateAssociations has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const updateAssociations = currentRows => {
                    const promises = [];
                    const unassociatedObjects = [];
                    const changedAssociations = [];
                    for (const obj of newInstances) {
              Severity: Major
              Found in src/associations/belongs-to-many.js - About 2 hrs to fix

                Function get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  async get(instance, options) {
                    options = Utils.cloneDeep(options) || {};
                
                    const through = this.through;
                    let scopeWhere;
                Severity: Minor
                Found in src/associations/belongs-to-many.js - About 1 hr 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 get has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async get(instance, options) {
                    options = Utils.cloneDeep(options) || {};
                
                    const through = this.through;
                    let scopeWhere;
                Severity: Minor
                Found in src/associations/belongs-to-many.js - About 1 hr to fix

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

                    async has(sourceInstance, instances, options) {
                      if (!Array.isArray(instances)) {
                        instances = [instances];
                      }
                  
                  
                  Severity: Minor
                  Found in src/associations/belongs-to-many.js - About 1 hr to fix

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

                      _createForeignAndOtherKeys() {
                        /*
                         * Default/generated foreign/other keys
                         */
                        if (_.isObject(this.options.foreignKey)) {
                    Severity: Minor
                    Found in src/associations/belongs-to-many.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

                        this.accessors = {
                          get: `get${plural}`,
                          set: `set${plural}`,
                          addMultiple: `add${plural}`,
                          add: `add${singular}`,
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 5 hrs to fix
                    src/associations/has-many.js on lines 91..102

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

                    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 (this.as) {
                          this.isAliased = true;
                    
                          if (_.isPlainObject(this.as)) {
                            this.options.name = this.as;
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 4 hrs to fix
                    src/associations/has-many.js on lines 36..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 118.

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

                        if (Object.prototype.hasOwnProperty.call(options, 'scope')) {
                          if (!options.scope) {
                            model = model.unscoped();
                          } else {
                            model = model.scope(options.scope);
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 3 other locations - About 1 hr to fix
                    src/associations/belongs-to.js on lines 132..138
                    src/associations/has-many.js on lines 224..230
                    src/associations/has-one.js on lines 134..140

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

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

                      verifyAssociationAlias(alias) {
                        if (typeof alias === 'string') {
                          return this.as === alias;
                        }
                    
                    
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 3 other locations - About 1 hr to fix
                    src/associations/belongs-to.js on lines 234..244
                    src/associations/has-many.js on lines 481..491
                    src/associations/has-one.js on lines 266..276

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

                    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

                      mixin(obj) {
                        const methods = [
                          'get',
                          'count',
                          'hasSingle',
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 1 hr to fix
                    src/associations/has-many.js on lines 146..167

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

                    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

                        this.oneFromTarget = new HasOne(this.target, this.through.model, {
                          foreignKey: this.otherKey,
                          sourceKey: this.targetKey,
                          as: this.through.model.name
                        });
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 1 hr to fix
                    src/associations/belongs-to-many.js on lines 362..366

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

                    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

                        this.oneFromSource = new HasOne(this.source, this.through.model, {
                          foreignKey: this.foreignKey,
                          sourceKey: this.sourceKey,
                          as: this.through.model.name
                        });
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 1 hr to fix
                    src/associations/belongs-to-many.js on lines 374..378

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

                    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.through.model.rawAttributes[this.otherKey]) {
                          this.through.model.rawAttributes[this.otherKey] = {
                            _autoGenerated: true
                          };
                        }
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 1 hr to fix
                    src/associations/belongs-to-many.js on lines 307..311

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

                    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.through.model.rawAttributes[this.foreignKey]) {
                          this.through.model.rawAttributes[this.foreignKey] = {
                            _autoGenerated: true
                          };
                        }
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 1 other location - About 1 hr to fix
                    src/associations/belongs-to-many.js on lines 313..317

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

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

                        if (Object.prototype.hasOwnProperty.call(options, 'schema')) {
                          model = model.schema(options.schema, options.schemaDelimiter);
                        }
                    Severity: Major
                    Found in src/associations/belongs-to-many.js and 3 other locations - About 40 mins to fix
                    src/associations/belongs-to.js on lines 140..142
                    src/associations/has-many.js on lines 232..234
                    src/associations/has-one.js on lines 142..144

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

                    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

                          sourceAttribute.onUpdate = this.options.onUpdate || this.through.model.rawAttributes[this.foreignKey].onUpdate;
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 35 mins to fix
                    src/associations/belongs-to-many.js on lines 325..325

                    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

                          sourceAttribute.onDelete = this.options.onDelete || this.through.model.rawAttributes[this.foreignKey].onDelete;
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 35 mins to fix
                    src/associations/belongs-to-many.js on lines 326..326

                    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

                          targetAttribute.onDelete = this.through.model.rawAttributes[this.otherKey].onDelete || this.options.onDelete;
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 35 mins to fix
                    src/associations/belongs-to-many.js on lines 337..337

                    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

                          targetAttribute.onUpdate = this.through.model.rawAttributes[this.otherKey].onUpdate || this.options.onUpdate;
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 35 mins to fix
                    src/associations/belongs-to-many.js on lines 336..336

                    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

                                  this.through.model.update(
                                    attributes,
                                    Object.assign(options, {
                                      where: {
                                        [identifier]: sourceInstance.get(sourceKey),
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 30 mins to fix
                    src/associations/belongs-to-many.js on lines 759..767

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

                    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

                              association.through.model.update(
                                attributes,
                                Object.assign(options, {
                                  where: {
                                    [identifier]: sourceInstance.get(sourceKey),
                    Severity: Minor
                    Found in src/associations/belongs-to-many.js and 1 other location - About 30 mins to fix
                    src/associations/belongs-to-many.js on lines 617..625

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

                    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

                    There are no issues that match your filters.

                    Category
                    Status