sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Avoid deeply nested control flow statements.
Open

            if (length) {
              for (i = 0; i < length; i++) {
                prefix = $parent ? `${$parent}.${$prevKeyPrefix[i]}` : $prevKeyPrefix[i];
                primaryKeyAttributes = includeMap[prefix].model.primaryKeyAttributes;
                $length = primaryKeyAttributes.length;
Severity: Major
Found in src/dialects/abstract/query.js - About 45 mins to fix

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

      handleSelectQuery(results) {
        let result = null;
    
        // Map raw fields to names if a mapping is provided
        if (this.options.fieldMap) {
    Severity: Minor
    Found in src/dialects/abstract/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 (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 (length) {
                    for (i = 0; i < length; i++) {
                      if (i === length - 1) {
                        values = $current[$keyPrefix[i]] = {};
                      }
      Severity: Major
      Found in src/dialects/abstract/query.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  for ($i = 0; $i < uniqueKeyAttributes.length; $i++) {
                    topHash += row[uniqueKeyAttributes[$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 = remainingEnumValues.length - 1; reverseIdx >= 0; reverseIdx--) {
                        addEnumValue(field, remainingEnumValues[reverseIdx], lastOldEnumValue, 'after');
                      }
          Severity: Major
          Found in src/dialects/postgres/query-interface.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

              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

                    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

                      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

                        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

                          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

                            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

                                            if (i < length - 1) {
                                              parentHash = itemHash;
                                            }
                                Severity: Major
                                Found in src/dialects/abstract/query.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language