sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

  generateReturnValues(modelAttributes, options) {
    const returnFields = [];
    const returnTypes = [];
    let outputFragment = '';
    let returningFragment = '';
Severity: Minor
Found in src/dialects/abstract/query-generator.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 formatBindParameters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  static formatBindParameters(sql, values, dialect) {
    let bindParam;
    if (Array.isArray(values)) {
      bindParam = {};
      values.forEach((v, i) => {
Severity: Minor
Found in src/dialects/sqlite/query.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 _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 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 _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 upsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async upsert(tableName, insertValues, updateValues, where, options) {
    options = { ...options };

    const model = options.model;
    const primaryKeys = Object.values(model.primaryKeys).map(item => item.field);
Severity: Minor
Found in src/dialects/abstract/query-interface.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

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 set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async set(sourceInstance, associatedInstance, options) {
    options = { ...options, scope: false };

    const oldInstance = await sourceInstance[this.accessors.get](options);
    // TODO Use equals method once #5605 is resolved
Severity: Minor
Found in src/associations/has-one.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 this.handleShowIndexesQuery(data);
Severity: Major
Found in src/dialects/mariadb/query.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return data;
    Severity: Major
    Found in src/dialects/mariadb/query.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return data[0];
      Severity: Major
      Found in src/dialects/mssql/query.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return rows;
        Severity: Major
        Found in src/dialects/postgres/query.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return value.slice();
          Severity: Major
          Found in src/utils.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return [data, meta];
            Severity: Major
            Found in src/dialects/mariadb/query.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return data;
              Severity: Major
              Found in src/dialects/mssql/query.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return [data, rowCount];
                Severity: Major
                Found in src/dialects/mssql/query.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return { ...value };
                  Severity: Major
                  Found in src/utils.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return [result, data.affectedRows];
                    Severity: Major
                    Found in src/dialects/mariadb/query.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language