sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

  async run(sql, parameters) {
    this.sql = sql;
    const { connection, options } = this;

    //do we need benchmark for this query execution
Severity: Minor
Found in src/dialects/mysql/query.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 _collectModels has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  _collectModels(include, prefix) {
    const ret = {};

    if (include) {
      for (const _include of include) {
Severity: Minor
Found in src/dialects/sqlite/query.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 getConnection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  async getConnection(options) {
    options = options || {};
    options.uuid = options.uuid || 'default';
    options.storage = this.sequelize.options.storage || this.sequelize.options.host || ':memory:';
    options.inMemory = options.storage === ':memory:' ? 1 : 0;
Severity: Minor
Found in src/dialects/sqlite/connection-manager.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 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 constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(source, target, options) {
    super(source, target, options);

    this.associationType = 'BelongsTo';
    this.isSingleAssociation = true;
Severity: Minor
Found in src/associations/belongs-to.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 constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(source, target, options) {
    super(source, target, options);

    this.associationType = 'HasOne';
    this.isSingleAssociation = true;
Severity: Minor
Found in src/associations/has-one.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 mapWhereFieldNames has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function mapWhereFieldNames(attributes, Model) {
  if (attributes) {
    getComplexKeys(attributes).forEach(attribute => {
      const rawAttribute = Model.rawAttributes[attribute];

Severity: Minor
Found in src/utils.js - About 1 hr to fix

    Function prepareEnvironment has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async prepareEnvironment(useCLS) {
        let connectionPromise;
    
        if (useCLS === undefined) {
          useCLS = true;
    Severity: Minor
    Found in src/transaction.js - About 1 hr to fix

      Function getConnection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async getConnection(options) {
          options = options || {};
          options.uuid = options.uuid || 'default';
          options.storage = this.sequelize.options.storage || this.sequelize.options.host || ':memory:';
          options.inMemory = options.storage === ':memory:' ? 1 : 0;
      Severity: Minor
      Found in src/dialects/sqlite/connection-manager.js - About 1 hr to fix

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

            const query = new Promise((resolve, reject) => {
              // TRANSACTION SUPPORT
              if (sql.startsWith('BEGIN TRANSACTION')) {
                return connection.beginTransaction(
                  error => (error ? reject(error) : resolve([])),
        Severity: Minor
        Found in src/dialects/mssql/query.js - About 1 hr to fix

          Function generateReturnValues has 30 lines of code (exceeds 25 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 1 hr to fix

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

              async run(sql, parameters) {
                this.sql = sql;
                const { connection, options } = this;
            
                //do we need benchmark for this query execution
            Severity: Minor
            Found in src/dialects/mysql/query.js - About 1 hr to fix

              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 upsert has 30 lines of code (exceeds 25 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 1 hr to fix

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

                    async describeTable(tableName, options) {
                      let schema = null;
                      let schemaDelimiter = null;
                  
                      if (typeof options === 'string') {
                  Severity: Minor
                  Found in src/dialects/abstract/query-interface.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 runHooks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async runHooks(hooks, ...hookArgs) {
                          if (!hooks) throw new Error('runHooks requires at least 1 argument');
                      
                          let hookType;
                      
                      
                      Severity: Minor
                      Found in src/hooks.js - About 1 hr to fix

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

                          async removeConstraint(tableName, constraintName, options) {
                            let createTableSql;
                        
                            const constraints = await this.showConstraint(tableName, constraintName);
                            // sqlite can't show only one constraint, so we find here the one to remove
                        Severity: Minor
                        Found in src/dialects/sqlite/query-interface.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language