sequelize/sequelize

View on GitHub
src/model.js

Summary

Maintainability
F
1 mo
Test Coverage

File model.js has 2942 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const assert = require('assert');
const _ = require('lodash');
const Dottie = require('dottie');

const Utils = require('./utils');
Severity: Major
Found in src/model.js - About 1 wk to fix

    Model has 93 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Model {
      static get queryInterface() {
        return this.sequelize.getQueryInterface();
      }
    
    
    Severity: Major
    Found in src/model.js - About 1 day to fix

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

        set(key, value, options) {
          let values;
          let originalValue;
      
          if (typeof key === 'object' && key !== null) {
      Severity: Minor
      Found in src/model.js - About 1 day 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 bulkCreate has 305 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static async bulkCreate(records, options = {}) {
          if (!records.length) {
            return [];
          }
      
      
      Severity: Major
      Found in src/model.js - About 1 day to fix

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

            const recursiveBulkCreate = async (instances, options) => {
              options = {
                validate: false,
                hooks: true,
                individualHooks: false,
        Severity: Major
        Found in src/model.js - About 1 day to fix

          Function save has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
          Open

            async save(options) {
              if (arguments.length > 1) {
                throw new Error('The second argument was removed in favor of the options object.');
              }
          
          
          Severity: Minor
          Found in src/model.js - About 1 day 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 sync has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
          Open

            static async sync(options) {
              options = { ...this.options, ...options };
              options.hooks = options.hooks === undefined ? true : !!options.hooks;
          
              const attributes = this.tableAttributes;
          Severity: Minor
          Found in src/model.js - About 1 day 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 save has 228 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async save(options) {
              if (arguments.length > 1) {
                throw new Error('The second argument was removed in favor of the options object.');
              }
          
          
          Severity: Major
          Found in src/model.js - About 1 day to fix

            Function bulkCreate has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
            Open

              static async bulkCreate(records, options = {}) {
                if (!records.length) {
                  return [];
                }
            
            
            Severity: Minor
            Found in src/model.js - About 1 day 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 _expandIncludeAllElement has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
            Open

              static _expandIncludeAllElement(includes, include) {
                // check 'all' attribute provided is valid
                let all = include.all;
                delete include.all;
            
            
            Severity: Minor
            Found in src/model.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

            Function update has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
            Open

              static async update(values, options) {
                options = Utils.cloneDeep(options);
            
                this._injectScope(options);
                this._optionsMustContainWhere(options);
            Severity: Minor
            Found in src/model.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 init has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
            Open

              static init(attributes, options = {}) {
                if (!options.sequelize) {
                  throw new Error('No Sequelize instance passed');
                }
            
            
            Severity: Minor
            Found in src/model.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 update has 152 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static async update(values, options) {
                options = Utils.cloneDeep(options);
            
                this._injectScope(options);
                this._optionsMustContainWhere(options);
            Severity: Major
            Found in src/model.js - About 6 hrs to fix

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

                static refreshAttributes() {
                  const attributeManipulation = {};
              
                  this.prototype._customGetters = {};
                  this.prototype._customSetters = {};
              Severity: Major
              Found in src/model.js - About 6 hrs to fix

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

                  get(key, options) {
                    if (options === undefined && typeof key === 'object') {
                      options = key;
                      key = undefined;
                    }
                Severity: Minor
                Found in src/model.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 _validateIncludedElement has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                  static _validateIncludedElement(include, tableNames, options) {
                    tableNames[include.model.getTableName()] = true;
                
                    if (include.attributes && !options.raw) {
                      include.model._expandAttributes(include);
                Severity: Minor
                Found in src/model.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 _conformInclude has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                Open

                  static _conformInclude(include, self) {
                    if (include) {
                      let model;
                
                      if (include._pseudo) return include;
                Severity: Minor
                Found in src/model.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 init has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static init(attributes, options = {}) {
                    if (!options.sequelize) {
                      throw new Error('No Sequelize instance passed');
                    }
                
                
                Severity: Major
                Found in src/model.js - About 5 hrs to fix

                  Function _validateIncludedElements has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                    static _validateIncludedElements(options, tableNames) {
                      if (!options.model) options.model = this;
                  
                      tableNames = tableNames || {};
                      options.includeNames = [];
                  Severity: Minor
                  Found in src/model.js - About 4 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 set has 110 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    set(key, value, options) {
                      let values;
                      let originalValue;
                  
                      if (typeof key === 'object' && key !== null) {
                  Severity: Major
                  Found in src/model.js - About 4 hrs to fix

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

                      static _validateIncludedElement(include, tableNames, options) {
                        tableNames[include.model.getTableName()] = true;
                    
                        if (include.attributes && !options.raw) {
                          include.model._expandAttributes(include);
                    Severity: Major
                    Found in src/model.js - About 4 hrs to fix

                      Function findOrCreate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                        static async findOrCreate(options) {
                          if (!options || !options.where || arguments.length > 1) {
                            throw new Error(
                              'Missing where attribute in the options parameter passed to findOrCreate. ' +
                                'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
                      Severity: Minor
                      Found in src/model.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 scope has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                      Open

                        static scope(option) {
                          const self = class extends this {};
                          let scope;
                          let scopeName;
                      
                      
                      Severity: Minor
                      Found in src/model.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 findOrCreate has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static async findOrCreate(options) {
                          if (!options || !options.where || arguments.length > 1) {
                            throw new Error(
                              'Missing where attribute in the options parameter passed to findOrCreate. ' +
                                'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
                      Severity: Major
                      Found in src/model.js - About 3 hrs to fix

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

                          static async sync(options) {
                            options = { ...this.options, ...options };
                            options.hooks = options.hooks === undefined ? true : !!options.hooks;
                        
                            const attributes = this.tableAttributes;
                        Severity: Major
                        Found in src/model.js - About 3 hrs to fix

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

                            static _expandIncludeAllElement(includes, include) {
                              // check 'all' attribute provided is valid
                              let all = include.all;
                              delete include.all;
                          
                          
                          Severity: Major
                          Found in src/model.js - About 3 hrs to fix

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

                              static _validateIncludedElements(options, tableNames) {
                                if (!options.model) options.model = this;
                            
                                tableNames = tableNames || {};
                                options.includeNames = [];
                            Severity: Major
                            Found in src/model.js - About 2 hrs to fix

                              Function findAll has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                                static async findAll(options) {
                                  if (options !== undefined && !_.isPlainObject(options)) {
                                    throw new sequelizeErrors.QueryError(
                                      'The argument passed to findAll must be an options object, use findByPk if you wish to pass a single primary key value'
                                    );
                              Severity: Minor
                              Found in src/model.js - About 2 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 findAll has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static async findAll(options) {
                                  if (options !== undefined && !_.isPlainObject(options)) {
                                    throw new sequelizeErrors.QueryError(
                                      'The argument passed to findAll must be an options object, use findByPk if you wish to pass a single primary key value'
                                    );
                              Severity: Major
                              Found in src/model.js - About 2 hrs to fix

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

                                  static async destroy(options) {
                                    options = Utils.cloneDeep(options);
                                
                                    this._injectScope(options);
                                
                                
                                Severity: Major
                                Found in src/model.js - About 2 hrs to fix

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

                                    static async increment(fields, options) {
                                      options = options || {};
                                      if (typeof fields === 'string') fields = [fields];
                                      if (Array.isArray(fields)) {
                                        fields = fields.map(f => {
                                  Severity: Major
                                  Found in src/model.js - About 2 hrs to fix

                                    Function _setInclude has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      _setInclude(key, value, options) {
                                        if (!Array.isArray(value)) value = [value];
                                        if (value[0] instanceof Model) {
                                          value = value.map(instance => instance.dataValues);
                                        }
                                    Severity: Minor
                                    Found in src/model.js - About 2 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 _addDefaultAttributes has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      static _addDefaultAttributes() {
                                        const tail = {};
                                        let head = {};
                                    
                                        // Add id if no primary key was manually added to definition
                                    Severity: Major
                                    Found in src/model.js - About 2 hrs to fix

                                      Function _initValues has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        _initValues(values, options) {
                                          let defaults;
                                          let key;
                                      
                                          values = { ...values };
                                      Severity: Minor
                                      Found in src/model.js - About 2 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 _initValues has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        _initValues(values, options) {
                                          let defaults;
                                          let key;
                                      
                                          values = { ...values };
                                      Severity: Major
                                      Found in src/model.js - About 2 hrs to fix

                                        Function increment has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          static async increment(fields, options) {
                                            options = options || {};
                                            if (typeof fields === 'string') fields = [fields];
                                            if (Array.isArray(fields)) {
                                              fields = fields.map(f => {
                                        Severity: Minor
                                        Found in src/model.js - About 2 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 upsert has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                          static async upsert(values, options) {
                                            options = {
                                              hooks: true,
                                              returning: true,
                                              validate: true,
                                        Severity: Major
                                        Found in src/model.js - About 2 hrs to fix

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

                                            static async restore(options) {
                                              if (!this._timestampAttributes.deletedAt) throw new Error('Model is not paranoid');
                                          
                                              options = {
                                                hooks: true,
                                          Severity: Minor
                                          Found in src/model.js - About 1 hr to fix

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

                                              get(key, options) {
                                                if (options === undefined && typeof key === 'object') {
                                                  options = key;
                                                  key = undefined;
                                                }
                                            Severity: Minor
                                            Found in src/model.js - About 1 hr to fix

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

                                                static scope(option) {
                                                  const self = class extends this {};
                                                  let scope;
                                                  let scopeName;
                                              
                                              
                                              Severity: Minor
                                              Found in src/model.js - About 1 hr to fix

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

                                                  static async aggregate(attribute, aggregateFunction, options) {
                                                    options = Utils.cloneDeep(options);
                                                
                                                    // We need to preserve attributes here as the `injectScope` call would inject non aggregate columns.
                                                    const prevAttributes = options.attributes;
                                                Severity: Minor
                                                Found in src/model.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 aggregate has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                  static async aggregate(attribute, aggregateFunction, options) {
                                                    options = Utils.cloneDeep(options);
                                                
                                                    // We need to preserve attributes here as the `injectScope` call would inject non aggregate columns.
                                                    const prevAttributes = options.attributes;
                                                Severity: Minor
                                                Found in src/model.js - About 1 hr to fix

                                                  Function _paranoidClause has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                    static _paranoidClause(model, options = {}) {
                                                      // Apply on each include
                                                      // This should be handled before handling where conditions because of logic with returns
                                                      // otherwise this code will never run on includes of a already conditionable where
                                                      if (options.include) {
                                                  Severity: Minor
                                                  Found in src/model.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 _conformInclude has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                    static _conformInclude(include, self) {
                                                      if (include) {
                                                        let model;
                                                  
                                                        if (include._pseudo) return include;
                                                  Severity: Minor
                                                  Found in src/model.js - About 1 hr to fix

                                                    Function upsert has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                      static async upsert(values, options) {
                                                        options = {
                                                          hooks: true,
                                                          returning: true,
                                                          validate: true,
                                                    Severity: Minor
                                                    Found in src/model.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 destroy has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                      async destroy(options) {
                                                        options = {
                                                          hooks: true,
                                                          force: false,
                                                          ...options
                                                    Severity: Minor
                                                    Found in src/model.js - About 1 hr to fix

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

                                                        static async _findSeparate(results, options) {
                                                          if (!options.include || options.raw || !results) return results;
                                                      
                                                          const original = results;
                                                          if (options.plain) results = [results];
                                                      Severity: Minor
                                                      Found in src/model.js - About 1 hr to fix

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

                                                          static _getIncludedAssociation(targetModel, targetAlias) {
                                                            const associations = this.getAssociations(targetModel);
                                                            let association = null;
                                                            if (associations.length === 0) {
                                                              throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is not associated to ${this.name}!`);
                                                        Severity: Minor
                                                        Found in src/model.js - About 1 hr to fix

                                                          Function destroy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                            static async destroy(options) {
                                                              options = Utils.cloneDeep(options);
                                                          
                                                              this._injectScope(options);
                                                          
                                                          
                                                          Severity: Minor
                                                          Found in src/model.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 _findAutoIncrementAttribute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                            static _findAutoIncrementAttribute() {
                                                              this.autoIncrementAttribute = null;
                                                          
                                                              for (const name in this.rawAttributes) {
                                                                if (Object.prototype.hasOwnProperty.call(this.rawAttributes, name)) {
                                                          Severity: Minor
                                                          Found in src/model.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 _mergeFunction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                            static _mergeFunction(objValue, srcValue, key) {
                                                              if (Array.isArray(objValue) && Array.isArray(srcValue)) {
                                                                return _.union(objValue, srcValue);
                                                              }
                                                              if (key === 'where' || key === 'having') {
                                                          Severity: Minor
                                                          Found in src/model.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 _setInclude has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                                          Open

                                                            _setInclude(key, value, options) {
                                                              if (!Array.isArray(value)) value = [value];
                                                              if (value[0] instanceof Model) {
                                                                value = value.map(instance => instance.dataValues);
                                                              }
                                                          Severity: Minor
                                                          Found in src/model.js - About 1 hr to fix

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

                                                              static _paranoidClause(model, options = {}) {
                                                                // Apply on each include
                                                                // This should be handled before handling where conditions because of logic with returns
                                                                // otherwise this code will never run on includes of a already conditionable where
                                                                if (options.include) {
                                                            Severity: Minor
                                                            Found in src/model.js - About 1 hr to fix

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

                                                                static async findOne(options) {
                                                                  if (options !== undefined && !_.isPlainObject(options)) {
                                                                    throw new Error(
                                                                      'The argument passed to findOne must be an options object, use findByPk if you wish to pass a single primary key value'
                                                                    );
                                                              Severity: Minor
                                                              Found in src/model.js - About 1 hr to fix

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

                                                                    (function addAllIncludes(parent, includes) {
                                                                      _.forEach(parent.associations, association => {
                                                                        if (all !== true && !all.includes(association.associationType)) {
                                                                          return;
                                                                        }
                                                                Severity: Minor
                                                                Found in src/model.js - About 1 hr to fix

                                                                  Function destroy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                    async destroy(options) {
                                                                      options = {
                                                                        hooks: true,
                                                                        force: false,
                                                                        ...options
                                                                  Severity: Minor
                                                                  Found in src/model.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

                                                                  Consider simplifying this complex logical expression.
                                                                  Open

                                                                        if (
                                                                          options.raw &&
                                                                          !(this._options && this._options.include) &&
                                                                          !(options && options.attributes) &&
                                                                          !this.constructor._hasDateAttributes &&
                                                                  Severity: Major
                                                                  Found in src/model.js - About 1 hr to fix

                                                                    Consider simplifying this complex logical expression.
                                                                    Open

                                                                          if (
                                                                            !options.raw &&
                                                                            // True when sequelize method
                                                                            (value instanceof Utils.SequelizeMethod ||
                                                                            // Check for data type type comparators
                                                                    Severity: Major
                                                                    Found in src/model.js - About 1 hr to fix

                                                                      Consider simplifying this complex logical expression.
                                                                      Open

                                                                                    if (
                                                                                      !!constraintName &&
                                                                                      foreignKeyReference.tableCatalog === database &&
                                                                                      (schema ? foreignKeyReference.tableSchema === schema : true) &&
                                                                                      foreignKeyReference.referencedTableName === references.model &&
                                                                      Severity: Major
                                                                      Found in src/model.js - About 1 hr to fix

                                                                        Consider simplifying this complex logical expression.
                                                                        Open

                                                                              if (
                                                                                options.attributes &&
                                                                                !options.raw &&
                                                                                this.primaryKeyAttribute &&
                                                                                !options.attributes.includes(this.primaryKeyAttribute) &&
                                                                        Severity: Major
                                                                        Found in src/model.js - About 1 hr to fix

                                                                          Avoid deeply nested control flow statements.
                                                                          Open

                                                                                              if (!(include.association instanceof BelongsToMany)) {
                                                                                                associationInstance.set(
                                                                                                  include.association.foreignKey,
                                                                                                  instance.get(include.association.sourceKey || instance.constructor.primaryKeyAttribute, {
                                                                                                    raw: true
                                                                          Severity: Major
                                                                          Found in src/model.js - About 45 mins to fix

                                                                            Avoid deeply nested control flow statements.
                                                                            Open

                                                                                                for (const attr of Object.keys(include.association.through.model.rawAttributes)) {
                                                                                                  if (
                                                                                                    include.association.through.model.rawAttributes[attr]._autoGenerated ||
                                                                                                    attr === include.association.foreignKey ||
                                                                                                    attr === include.association.otherKey ||
                                                                            Severity: Major
                                                                            Found in src/model.js - About 45 mins to fix

                                                                              Avoid deeply nested control flow statements.
                                                                              Open

                                                                                          if (!_.isEqual(previousNestedValue, value)) {
                                                                                            Dottie.set(this.dataValues, key, value);
                                                                                            this.changed(key.split('.')[0], true);
                                                                                          }
                                                                              Severity: Major
                                                                              Found in src/model.js - About 45 mins to fix

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

                                                                                  constructor(values = {}, options = {}) {
                                                                                    options = {
                                                                                      isNewRecord: true,
                                                                                      _schema: this.constructor._schema,
                                                                                      _schemaDelimiter: this.constructor._schemaDelimiter,
                                                                                Severity: Minor
                                                                                Found in src/model.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

                                                                                Avoid deeply nested control flow statements.
                                                                                Open

                                                                                                      if (
                                                                                                        include.association.through.model.rawAttributes[attr]._autoGenerated ||
                                                                                                        attr === include.association.foreignKey ||
                                                                                                        attr === include.association.otherKey ||
                                                                                                        typeof instance[include.association.through.model.name][attr] === undefined
                                                                                Severity: Major
                                                                                Found in src/model.js - About 45 mins to fix

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

                                                                                    static _addDefaultAttributes() {
                                                                                      const tail = {};
                                                                                      let head = {};
                                                                                  
                                                                                      // Add id if no primary key was manually added to definition
                                                                                  Severity: Minor
                                                                                  Found in src/model.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

                                                                                  Avoid deeply nested control flow statements.
                                                                                  Open

                                                                                                if (values[k] === undefined) {
                                                                                                  continue;
                                                                                                }
                                                                                  Severity: Major
                                                                                  Found in src/model.js - About 45 mins to fix

                                                                                    Avoid deeply nested control flow statements.
                                                                                    Open

                                                                                                if (!all.includes(types[j])) {
                                                                                                  all.unshift(types[j]);
                                                                                                  i++;
                                                                                                }
                                                                                    Severity: Major
                                                                                    Found in src/model.js - About 45 mins to fix

                                                                                      Avoid deeply nested control flow statements.
                                                                                      Open

                                                                                                  for (const foreignKeyReference of foreignKeyReferences) {
                                                                                                    const constraintName = foreignKeyReference.constraintName;
                                                                                                    if (
                                                                                                      !!constraintName &&
                                                                                                      foreignKeyReference.tableCatalog === database &&
                                                                                      Severity: Major
                                                                                      Found in src/model.js - About 45 mins to fix

                                                                                        Consider simplifying this complex logical expression.
                                                                                        Open

                                                                                              if (Object.prototype.hasOwnProperty.call(definition, 'unique') && definition.unique) {
                                                                                                let idxName;
                                                                                                if (typeof definition.unique === 'object' && Object.prototype.hasOwnProperty.call(definition.unique, 'name')) {
                                                                                                  idxName = definition.unique.name;
                                                                                                } else if (typeof definition.unique === 'string') {
                                                                                        Severity: Major
                                                                                        Found in src/model.js - About 40 mins to fix

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

                                                                                            static async restore(options) {
                                                                                              if (!this._timestampAttributes.deletedAt) throw new Error('Model is not paranoid');
                                                                                          
                                                                                              options = {
                                                                                                hooks: true,
                                                                                          Severity: Minor
                                                                                          Found in src/model.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 refreshAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            static refreshAttributes() {
                                                                                              const attributeManipulation = {};
                                                                                          
                                                                                              this.prototype._customGetters = {};
                                                                                              this.prototype._customSetters = {};
                                                                                          Severity: Minor
                                                                                          Found in src/model.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 bulkBuild has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            static bulkBuild(valueSets, options) {
                                                                                              options = { isNewRecord: true, ...options };
                                                                                          
                                                                                              if (!options.includeValidated) {
                                                                                                this._conformIncludes(options, this);
                                                                                          Severity: Minor
                                                                                          Found in src/model.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 _getIncludedAssociation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            static _getIncludedAssociation(targetModel, targetAlias) {
                                                                                              const associations = this.getAssociations(targetModel);
                                                                                              let association = null;
                                                                                              if (associations.length === 0) {
                                                                                                throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is not associated to ${this.name}!`);
                                                                                          Severity: Minor
                                                                                          Found in src/model.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 _injectDependentVirtualAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            static _injectDependentVirtualAttributes(attributes) {
                                                                                              if (!this._hasVirtualAttributes) return attributes;
                                                                                              if (!attributes || !Array.isArray(attributes)) return attributes;
                                                                                          
                                                                                              for (const attribute of attributes) {
                                                                                          Severity: Minor
                                                                                          Found in src/model.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 findCreateFind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                                          Open

                                                                                            static async findCreateFind(options) {
                                                                                              if (!options || !options.where) {
                                                                                                throw new Error('Missing where attribute in the options parameter passed to findCreateFind.');
                                                                                              }
                                                                                          
                                                                                          
                                                                                          Severity: Minor
                                                                                          Found in src/model.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

                                                                                          Avoid too many return statements within this function.
                                                                                          Open

                                                                                                return values;
                                                                                          Severity: Major
                                                                                          Found in src/model.js - About 30 mins to fix

                                                                                            Avoid too many return statements within this function.
                                                                                            Open

                                                                                                  return this.dataValues[key];
                                                                                            Severity: Major
                                                                                            Found in src/model.js - About 30 mins to fix

                                                                                              Avoid too many return statements within this function.
                                                                                              Open

                                                                                                  return srcValue === undefined ? objValue : srcValue;
                                                                                              Severity: Major
                                                                                              Found in src/model.js - About 30 mins to fix

                                                                                                Avoid too many return statements within this function.
                                                                                                Open

                                                                                                    return this.dataValues;
                                                                                                Severity: Major
                                                                                                Found in src/model.js - About 30 mins to fix

                                                                                                  Avoid too many return statements within this function.
                                                                                                  Open

                                                                                                            return include;
                                                                                                  Severity: Major
                                                                                                  Found in src/model.js - About 30 mins to fix

                                                                                                    Avoid too many return statements within this function.
                                                                                                    Open

                                                                                                              return include;
                                                                                                    Severity: Major
                                                                                                    Found in src/model.js - About 30 mins to fix

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

                                                                                                          return this;
                                                                                                      Severity: Major
                                                                                                      Found in src/model.js - About 30 mins to fix

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                            return this._changed.has(key);
                                                                                                        Severity: Major
                                                                                                        Found in src/model.js - About 30 mins to fix

                                                                                                          Avoid too many return statements within this function.
                                                                                                          Open

                                                                                                                    return this;
                                                                                                          Severity: Major
                                                                                                          Found in src/model.js - About 30 mins to fix

                                                                                                            Function findOne has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                            Open

                                                                                                              static async findOne(options) {
                                                                                                                if (options !== undefined && !_.isPlainObject(options)) {
                                                                                                                  throw new Error(
                                                                                                                    'The argument passed to findOne must be an options object, use findByPk if you wish to pass a single primary key value'
                                                                                                                  );
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.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

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

                                                                                                                              if (associationInstance[include.association.through.model.name]) {
                                                                                                                                for (const attr of Object.keys(include.association.through.model.rawAttributes)) {
                                                                                                                                  if (
                                                                                                                                    include.association.through.model.rawAttributes[attr]._autoGenerated ||
                                                                                                                                    attr === include.association.foreignKey ||
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 day to fix
                                                                                                            src/model.js on lines 4269..4281

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

                                                                                                            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 (instance[include.association.through.model.name]) {
                                                                                                                                for (const attr of Object.keys(include.association.through.model.rawAttributes)) {
                                                                                                                                  if (
                                                                                                                                    include.association.through.model.rawAttributes[attr]._autoGenerated ||
                                                                                                                                    attr === include.association.foreignKey ||
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 day to fix
                                                                                                            src/model.js on lines 2942..2954

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

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

                                                                                                                  if (
                                                                                                                    this.constructor._timestampAttributes.createdAt &&
                                                                                                                    defaults[this.constructor._timestampAttributes.createdAt]
                                                                                                                  ) {
                                                                                                                    this.dataValues[this.constructor._timestampAttributes.createdAt] = Utils.toDefaultValue(
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 2 other locations - About 4 hrs to fix
                                                                                                            src/model.js on lines 192..201
                                                                                                            src/model.js on lines 203..212

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

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

                                                                                                                  if (
                                                                                                                    this.constructor._timestampAttributes.deletedAt &&
                                                                                                                    defaults[this.constructor._timestampAttributes.deletedAt]
                                                                                                                  ) {
                                                                                                                    this.dataValues[this.constructor._timestampAttributes.deletedAt] = Utils.toDefaultValue(
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 2 other locations - About 4 hrs to fix
                                                                                                            src/model.js on lines 181..190
                                                                                                            src/model.js on lines 192..201

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

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

                                                                                                                  if (
                                                                                                                    this.constructor._timestampAttributes.updatedAt &&
                                                                                                                    defaults[this.constructor._timestampAttributes.updatedAt]
                                                                                                                  ) {
                                                                                                                    this.dataValues[this.constructor._timestampAttributes.updatedAt] = Utils.toDefaultValue(
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 2 other locations - About 4 hrs to fix
                                                                                                            src/model.js on lines 181..190
                                                                                                            src/model.js on lines 203..212

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

                                                                                                            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.options.updatedAt !== false) {
                                                                                                                    this._timestampAttributes.updatedAt =
                                                                                                                      typeof this.options.updatedAt === 'string' ? this.options.updatedAt : 'updatedAt';
                                                                                                                    this._readOnlyAttributes.add(this._timestampAttributes.updatedAt);
                                                                                                                  }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 2 hrs to fix
                                                                                                            src/model.js on lines 1119..1123

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

                                                                                                            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.options.createdAt !== false) {
                                                                                                                    this._timestampAttributes.createdAt =
                                                                                                                      typeof this.options.createdAt === 'string' ? this.options.createdAt : 'createdAt';
                                                                                                                    this._readOnlyAttributes.add(this._timestampAttributes.createdAt);
                                                                                                                  }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 2 hrs to fix
                                                                                                            src/model.js on lines 1124..1128

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

                                                                                                            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 (
                                                                                                                    include.attributes &&
                                                                                                                    include.attributes.length &&
                                                                                                                    !_.flattenDepth(include.attributes, 2).includes(association.foreignKey)
                                                                                                                  ) {
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 750..756

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

                                                                                                            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 (
                                                                                                                    options.attributes &&
                                                                                                                    options.attributes.length &&
                                                                                                                    !_.flattenDepth(options.attributes, 2).includes(association.sourceKey)
                                                                                                                  ) {
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 758..764

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

                                                                                                            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

                                                                                                                        const includeOptions = _(Utils.cloneDeep(include))
                                                                                                                          .omit(['association'])
                                                                                                                          .defaults({
                                                                                                                            transaction: options.transaction,
                                                                                                                            logging: options.logging,
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 4162..4169

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

                                                                                                            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

                                                                                                                        const includeOptions = _(Utils.cloneDeep(include))
                                                                                                                          .omit(['association'])
                                                                                                                          .defaults({
                                                                                                                            transaction: options.transaction,
                                                                                                                            logging: options.logging,
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 4246..4253

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

                                                                                                            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

                                                                                                                          const includeOptions = _(Utils.cloneDeep(include))
                                                                                                                            .omit(['association'])
                                                                                                                            .defaults({
                                                                                                                              transaction: options.transaction,
                                                                                                                              logging: options.logging
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 2764..2770

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

                                                                                                            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

                                                                                                                            const includeOptions = _(Utils.cloneDeep(include))
                                                                                                                              .omit(['association'])
                                                                                                                              .defaults({
                                                                                                                                transaction: options.transaction,
                                                                                                                                logging: options.logging
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 2915..2921

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

                                                                                                            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 (!options.includeValidated) {
                                                                                                                  this._conformIncludes(options, this);
                                                                                                                  if (options.include) {
                                                                                                                    this._expandIncludeAll(options);
                                                                                                                    this._validateIncludedElements(options);
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 2646..2652

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

                                                                                                            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 (!options.includeValidated) {
                                                                                                                  this._conformIncludes(options, this);
                                                                                                                  if (options.include) {
                                                                                                                    this._expandIncludeAll(options);
                                                                                                                    this._validateIncludedElements(options);
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 2268..2274

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

                                                                                                            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 (options.attributes) {
                                                                                                                  options.attributes = options.attributes.map(attribute => (Array.isArray(attribute) ? attribute[1] : attribute));
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 126..128

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

                                                                                                            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 (options.attributes) {
                                                                                                                  options.attributes = options.attributes.map(attribute => (Array.isArray(attribute) ? attribute[1] : attribute));
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 2276..2278

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

                                                                                                            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 (versionAttr && options.fields.length >= 1 && !options.fields.includes(versionAttr)) {
                                                                                                                  options.fields.push(versionAttr);
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 4076..4078

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

                                                                                                            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 (updatedAtAttr && options.fields.length >= 1 && !options.fields.includes(updatedAtAttr)) {
                                                                                                                  options.fields.push(updatedAtAttr);
                                                                                                                }
                                                                                                            Severity: Major
                                                                                                            Found in src/model.js and 1 other location - About 1 hr to fix
                                                                                                            src/model.js on lines 4079..4081

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

                                                                                                            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._timestampAttributes.updatedAt) {
                                                                                                                  tail[this._timestampAttributes.updatedAt] = {
                                                                                                                    type: DataTypes.DATE,
                                                                                                                    allowNull: false,
                                                                                                                    _autoGenerated: true
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 55 mins to fix
                                                                                                            src/model.js on lines 297..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 54.

                                                                                                            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._timestampAttributes.createdAt) {
                                                                                                                  tail[this._timestampAttributes.createdAt] = {
                                                                                                                    type: DataTypes.DATE,
                                                                                                                    allowNull: false,
                                                                                                                    _autoGenerated: true
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 55 mins to fix
                                                                                                            src/model.js on lines 305..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 54.

                                                                                                            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 (updatedAtAttr && !values[updatedAtAttr]) {
                                                                                                                        values[updatedAtAttr] = now;
                                                                                                                        if (!options.fields.includes(updatedAtAttr)) {
                                                                                                                          options.fields.push(updatedAtAttr);
                                                                                                                        }
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 50 mins to fix
                                                                                                            src/model.js on lines 2792..2797

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

                                                                                                            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 (createdAtAttr && !values[createdAtAttr]) {
                                                                                                                        values[createdAtAttr] = now;
                                                                                                                        if (!options.fields.includes(createdAtAttr)) {
                                                                                                                          options.fields.push(createdAtAttr);
                                                                                                                        }
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 50 mins to fix
                                                                                                            src/model.js on lines 2798..2803

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

                                                                                                            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 (options.individualHooks) {
                                                                                                                  await Promise.all(instances.map(instance => this.runHooks('afterDestroy', instance, options)));
                                                                                                                }
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 45 mins to fix
                                                                                                            src/model.js on lines 3193..3195

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

                                                                                                            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 (options.individualHooks) {
                                                                                                                  await Promise.all(instances.map(instance => this.runHooks('afterRestore', instance, options)));
                                                                                                                }
                                                                                                            Severity: Minor
                                                                                                            Found in src/model.js and 1 other location - About 45 mins to fix
                                                                                                            src/model.js on lines 3119..3121

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

                                                                                                            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