sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Avoid deeply nested control flow statements.
Open

              if (!item) {
                item = previousModel.getAssociationForAlias(model, model.name);
              }
Severity: Major
Found in src/dialects/abstract/query-generator.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (newIdx === -1) {
                  continue;
                }
    Severity: Major
    Found in src/dialects/postgres/query-interface.js - About 45 mins to fix

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

        selectFromTableFragment(options, model, attributes, tables, mainTableAs) {
          this._throwOnEmptyAttributes(attributes, {
            modelName: model && model.name,
            as: mainTableAs
          });
      Severity: Minor
      Found in src/dialects/abstract/query-generator.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 (Array.isArray(options.order[i])) {
                      options.order[i][0] = alias;
                    } else {
                      options.order[i] = alias;
                    }
      Severity: Major
      Found in src/dialects/abstract/query-generator.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (itemHash === topHash) {
                      if (!resultMap[itemHash]) {
                        resultMap[itemHash] = values;
                      } else {
                        topExists = true;
        Severity: Major
        Found in src/dialects/abstract/query.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (newIdx > rightestPosition) {
                        rightestPosition = newIdx;
                      }
          Severity: Major
          Found in src/dialects/postgres/query-interface.js - About 45 mins to fix

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

              _whereGroupBind(key, value, options) {
                const binding = key === Op.or ? this.OperatorMap[Op.or] : this.OperatorMap[Op.and];
                const outerBinding = key === Op.not ? 'NOT ' : '';
            
                if (Array.isArray(value)) {
            Severity: Minor
            Found in src/dialects/abstract/query-generator.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 (dataType.includes(' REFERENCES')) {
                          dataTypeString += dataType.substr(dataType.indexOf(' REFERENCES'));
                        }
            Severity: Major
            Found in src/dialects/sqlite/query-generator.js - About 45 mins to fix

              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

                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

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

                    _loadDialectModule(moduleName) {
                      try {
                        if (this.sequelize.config.dialectModulePath) {
                          return require(this.sequelize.config.dialectModulePath);
                        }
                  Severity: Minor
                  Found in src/dialects/abstract/connection-manager.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 (!parentHash) {
                                parentHash = topHash;
                              }
                  Severity: Major
                  Found in src/dialects/abstract/query.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 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

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

                                      if (dataType.includes('NOT NULL')) {
                                        dataTypeString = dataType.replace(' PRIMARY KEY', '');
                                      } else {
                                        dataTypeString = dataType.replace('PRIMARY KEY', 'NOT NULL');
                                      }
                          Severity: Major
                          Found in src/dialects/sqlite/query-generator.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 (!_.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
                                Severity
                                Category
                                Status
                                Source
                                Language