sequelize/sequelize

View on GitHub

Showing 787 of 787 total issues

Function getWhereConditions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  getWhereConditions(smth, tableName, factory, options, prepend) {
    const where = {};

    if (Array.isArray(tableName)) {
      tableName = tableName[0];
Severity: Minor
Found in src/dialects/abstract/query-generator.js - About 3 hrs 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 25 (exceeds 5 allowed). Consider refactoring.
Open

  formatError(err) {
    const errCode = err.errno || err.code;

    switch (errCode) {
      case 1062: {
Severity: Minor
Found in src/dialects/mysql/query.js - About 3 hrs 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 findOrCreate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  static async findOrCreate(options) {
    if (!options || !options.where || arguments.length > 1) {
      throw new Error(
        'Missing where attribute in the options parameter passed to findOrCreate. ' +
          'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
Severity: Minor
Found in src/model.js - About 3 hrs 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 escape has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export function escape(val: unknown, timeZone: string | null, dialect: string, format = false): string {
  let prependN = false;
  if (val === undefined || val === null) {
    return 'NULL';
  }
Severity: Minor
Found in src/sql-string.ts - About 3 hrs 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 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  formatError(err) {
    let match;
    let table;
    let index;
    let fields;
Severity: Major
Found in src/dialects/postgres/query.js - About 3 hrs to fix

    Function generateJoin has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      generateJoin(include, topLevelInfo) {
        const association = include.association;
        const parent = include.parent;
        const parentIsTop =
          !!parent && !include.parent.association && include.parent.model.name === topLevelInfo.options.model.name;
    Severity: Major
    Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

      Function initPools has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initPools() {
          const config = this.config;
      
          if (!config.replication) {
            this.pool = new Pool({
      Severity: Major
      Found in src/dialects/abstract/connection-manager.js - About 3 hrs to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if (this.as) {
              this.isAliased = true;
              this.options.name = {
                singular: this.as
              };
        Severity: Major
        Found in src/associations/has-one.js and 1 other location - About 3 hrs to fix
        src/associations/belongs-to.js on lines 22..30

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if (this.as) {
              this.isAliased = true;
              this.options.name = {
                singular: this.as
              };
        Severity: Major
        Found in src/associations/belongs-to.js and 1 other location - About 3 hrs to fix
        src/associations/has-one.js on lines 23..31

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function handleInsertQuery has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          handleInsertQuery(results, metaData) {
            if (this.instance) {
              // add the inserted row id to the instance
              const autoIncrementAttribute = this.model.autoIncrementAttribute;
              let id = null;
        Severity: Minor
        Found in src/dialects/mssql/query.js - About 3 hrs 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 24 (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/abstract/query-generator.js - About 3 hrs 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 24 (exceeds 5 allowed). Consider refactoring.
        Open

          async getConnection(options) {
            options = options || {};
        
            if (this.sequelize.options.databaseVersion === 0) {
              if (!this.versionPromise) {
        Severity: Minor
        Found in src/dialects/abstract/connection-manager.js - About 3 hrs 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 scope has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          static scope(option) {
            const self = class extends this {};
            let scope;
            let scopeName;
        
        
        Severity: Minor
        Found in src/model.js - About 3 hrs 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 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async set(sourceInstance, newAssociatedObjects, options) {
            options = options || {};
        
            const sourceKey = this.sourceKey;
            const targetKey = this.targetKey;
        Severity: Major
        Found in src/associations/belongs-to-many.js - About 3 hrs to fix

          Function upsertQuery has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            upsertQuery(tableName, insertValues, updateValues, where, model) {
              const targetTableAlias = this.quoteTable(`${tableName}_target`);
              const sourceTableAlias = this.quoteTable(`${tableName}_source`);
              const primaryKeysAttrs = [];
              const identityAttrs = [];
          Severity: Major
          Found in src/dialects/mssql/query-generator.js - About 3 hrs to fix

            Function findOrCreate has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static async findOrCreate(options) {
                if (!options || !options.where || arguments.length > 1) {
                  throw new Error(
                    'Missing where attribute in the options parameter passed to findOrCreate. ' +
                      'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
            Severity: Major
            Found in src/model.js - About 3 hrs to fix

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                    for (const _warningResult of _warningRow) {
                      if (Object.prototype.hasOwnProperty.call(_warningResult, 'Message')) {
                        messages.push(_warningResult.Message);
                      } else {
                        for (const _objectKey of _warningResult.keys()) {
              Severity: Major
              Found in src/dialects/mysql/query.js and 1 other location - About 3 hrs to fix
              src/dialects/mariadb/query.js on lines 199..207

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 102.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                    for (const _warningResult of _warningRow) {
                      if (Object.prototype.hasOwnProperty.call(_warningResult, 'Message')) {
                        messages.push(_warningResult.Message);
                      } else {
                        for (const _objectKey of _warningResult.keys()) {
              Severity: Major
              Found in src/dialects/mariadb/query.js and 1 other location - About 3 hrs to fix
              src/dialects/mysql/query.js on lines 177..185

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 102.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  static parse(value) {
                    value = value.buffer();
                    // Empty buffer, MySQL doesn't support POINT EMPTY
                    // check, https://dev.mysql.com/worklog/task/?id=2381
                    if (!value || value.length === 0) {
              Severity: Major
              Found in src/dialects/mariadb/data-types.js and 1 other location - About 3 hrs to fix
              src/dialects/mysql/data-types.js on lines 101..111

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 101.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  static parse(value) {
                    value = value.buffer();
                    // Empty buffer, MySQL doesn't support POINT EMPTY
                    // check, https://dev.mysql.com/worklog/task/?id=2381
                    if (!value || value.length === 0) {
              Severity: Major
              Found in src/dialects/mysql/data-types.js and 1 other location - About 3 hrs to fix
              src/dialects/mariadb/data-types.js on lines 93..103

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 101.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language