sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

  normalizeDataType(Type) {
    let type = typeof Type === 'function' ? new Type() : Type;
    const dialectTypes = this.dialect.DataTypes || {};

    if (dialectTypes[type.key]) {
Severity: Minor
Found in src/sequelize.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 (/(UPDATE|DELETE)/.test(defParts[i])) {
              row[`on_${defParts[i].toLowerCase()}`] = defParts[i + 1];
            }
Severity: Major
Found in src/dialects/postgres/query.js - About 45 mins to fix

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

    function mapOptionFieldNames(options, Model) {
      if (Array.isArray(options.attributes)) {
        options.attributes = options.attributes.map(attr => {
          // Object lookups will force any variable to strings, we don't want that for special objects etc
          if (typeof attr !== 'string') return attr;
    Severity: Minor
    Found in src/utils.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

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

      selectFromTableFragment(options, model, attributes, tables, mainTableAs, where) {
        this._throwOnEmptyAttributes(attributes, {
          modelName: model && model.name,
          as: mainTableAs
        });
    Severity: Minor
    Found in src/dialects/mssql/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 (split[1].toLowerCase() !== 'regclass)') {
                  result[row.Field].defaultValue = split[0];
                }
    Severity: Major
    Found in src/dialects/postgres/query.js - About 45 mins to fix

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

      function toDefaultValue(value, dialect) {
        if (typeof value === 'function') {
          const tmp = value();
          if (tmp instanceof DataTypes.ABSTRACT) {
            return tmp.toSql();
      Severity: Minor
      Found in src/utils.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

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

        async _invokeCustomValidator(validator, validatorType, optAttrDefined, optValue, optField) {
          let isAsync = false;
      
          const validatorArity = validator.length;
          // check if validator is async and requires a callback
      Severity: Minor
      Found in src/instance-validator.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

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

        async prepareEnvironment(useCLS) {
          let connectionPromise;
      
          if (useCLS === undefined) {
            useCLS = true;
      Severity: Minor
      Found in src/transaction.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

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

        _extractValidatorArgs(test, validatorType, field) {
          let validatorArgs = test.args || test;
          const isLocalizedValidator =
            typeof validatorArgs !== 'string' &&
            (validatorType === 'isAlpha' || validatorType === 'isAlphanumeric' || validatorType === 'isMobilePhone');
      Severity: Minor
      Found in src/instance-validator.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

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

        async run(sql, parameters) {
          this.sql = sql;
          const { connection, options } = this;
      
          const showWarnings = this.sequelize.options.showWarnings || options.showWarnings;
      Severity: Minor
      Found in src/dialects/mariadb/query.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 (newIdx > rightestPosition) {
                    rightestPosition = newIdx;
                  }
      Severity: Major
      Found in src/dialects/postgres/query-interface.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (Array.isArray(order)) {
                        order = order[0];
                      }
        Severity: Major
        Found in src/dialects/abstract/query-generator.js - About 45 mins to fix

          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 ($length === 1) {
                          itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[0]}`]);
                        } else if ($length > 0) {
                          for ($i = 0; $i < $length; $i++) {
                            itemHash += stringify(row[`${prefix}.${primaryKeyAttributes[$i]}`]);
            Severity: Major
            Found in src/dialects/abstract/query.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          for (let reverseIdx = newValuesBefore.length - 1; reverseIdx >= 0; reverseIdx--) {
                            if (~enumVals.indexOf(newValuesBefore[reverseIdx])) {
                              break;
                            }
              
              
              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

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

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

                    whereItemsQuery(where, options, binding) {
                      if (where === null || where === undefined || Utils.getComplexSize(where) === 0) {
                        // NO OP
                        return '';
                      }
                  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 (previousModel.rawAttributes[itemSplit[0]].type instanceof DataTypes.JSON) {
                                  // just quote identifiers for now
                                  const identifier = this.quoteIdentifiers(
                                    `${previousModel.name}.${previousModel.rawAttributes[itemSplit[0]].field}`
                                  );
                  Severity: Major
                  Found in src/dialects/abstract/query-generator.js - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language