sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function logWarnings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async logWarnings(results) {
    const warningResults = await this.run('SHOW WARNINGS');
    const warningMessage = `MySQL Warnings (${this.connection.uuid || 'default'}): `;
    const messages = [];
    for (const _warningRow of warningResults) {
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 _checkValidJsonStatement has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  _checkValidJsonStatement(stmt) {
    if (typeof stmt !== 'string') {
      return false;
    }

Severity: Minor
Found in src/dialects/sqlite/query-generator.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 delete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async delete(instance, tableName, identifier, options) {
    const cascades = [];
    const sql = this.queryGenerator.deleteQuery(tableName, identifier, {}, instance.constructor);

    options = { ...options };
Severity: Minor
Found in src/dialects/abstract/query-interface.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 rawSelect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  async rawSelect(tableName, options, attributeSelector, Model) {
    options = Utils.cloneDeep(options);
    options = _.defaults(options, {
      raw: true,
      plain: true,
Severity: Minor
Found in src/dialects/abstract/query-interface.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 formatError has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  formatError(err) {
    switch (err.code) {
      case 'SQLITE_CONSTRAINT': {
        if (err.message.includes('FOREIGN KEY constraint failed')) {
          return new sequelizeErrors.ForeignKeyConstraintError({
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 _paranoidClause has a Cognitive Complexity of 13 (exceeds 5 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

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 getQueryOrders has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getQueryOrders(options, model, subQuery) {
    const mainQueryOrder = [];
    const subQueryOrder = [];

    if (Array.isArray(options.order)) {
Severity: Minor
Found in src/dialects/abstract/query-generator.js - About 1 hr to fix

    Function _conformInclude has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static _conformInclude(include, self) {
        if (include) {
          let model;
    
          if (include._pseudo) return include;
    Severity: Minor
    Found in src/model.js - About 1 hr to fix

      Function _checkValidJsonStatement has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _checkValidJsonStatement(stmt) {
          if (typeof stmt !== 'string') {
            return false;
          }
      
      
      Severity: Minor
      Found in src/dialects/sqlite/query-generator.js - About 1 hr to fix

        Function parseConstraintsFromSql has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          parseConstraintsFromSql(sql) {
            let constraints = sql.split('CONSTRAINT ');
            let referenceTableName, referenceTableKeys, updateAction, deleteAction;
            constraints.splice(0, 1);
            constraints = constraints.map(constraintSql => {
        Severity: Minor
        Found in src/dialects/sqlite/query.js - About 1 hr to fix

          Function includeAttributes has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                const includeAttributes = include.attributes.map(attr => {
                  let attrAs = attr;
                  let verbatim = false;
          
                  if (Array.isArray(attr) && attr.length === 2) {
          Severity: Minor
          Found in src/dialects/abstract/query-generator.js - About 1 hr to fix

            Function dropSchema has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              dropSchema(schema) {
                // Mimics Postgres CASCADE, will drop objects belonging to the schema
                const quotedSchema = wrapSingleQuote(schema);
                return [
                  'IF EXISTS (SELECT schema_name',
            Severity: Minor
            Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

              Function describeTableQuery has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                describeTableQuery(tableName, schema) {
                  let sql = [
                    'SELECT',
                    "c.COLUMN_NAME AS 'Name',",
                    "c.DATA_TYPE AS 'Type',",
              Severity: Minor
              Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

                Function log has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  log(...args) {
                    let options;
                
                    const last = _.last(args);
                
                
                Severity: Minor
                Found in src/sequelize.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 handleSequelizeMethod has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  handleSequelizeMethod(smth, tableName, factory, options, prepend) {
                    if (smth instanceof Utils.Json) {
                      // Parse nested object
                      if (smth.conditions) {
                        const conditions = this.parseConditionObject(smth.conditions).map(
                Severity: Minor
                Found in src/dialects/postgres/query-generator.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 getUniqueConstraintErrorMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  getUniqueConstraintErrorMessage(field) {
                    let message = field ? `${field} must be unique` : 'Must be unique';
                
                    if (field && this.model) {
                      for (const key of Object.keys(this.model.uniqueKeys)) {
                Severity: Minor
                Found in src/dialects/abstract/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 stringify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                function stringify(data) {
                  if (data === null) return null;
                
                  if (!Array.isArray(data)) throw new Error('range must be an array');
                  if (!data.length) return 'empty';
                Severity: Minor
                Found in src/dialects/postgres/range.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  validate(value, field, options) {
                    if (this.typeValidation && field.type.validate && value) {
                      try {
                        if (options.isList && Array.isArray(value)) {
                          for (const item of value) {
                Severity: Minor
                Found in src/dialects/abstract/query-generator.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 updateQuery has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  updateQuery(tableName, attrValueHash, where, options, attributes) {
                    options = options || {};
                    _.defaults(options, this.options);
                
                    attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, options.omitNull, options);
                Severity: Minor
                Found in src/dialects/sqlite/query-generator.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 upsert has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  static async upsert(values, options) {
                    options = {
                      hooks: true,
                      returning: true,
                      validate: true,
                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

                Severity
                Category
                Status
                Source
                Language