sequelize/sequelize

View on GitHub

Showing 787 of 787 total issues

Function init has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  static init(attributes, options = {}) {
    if (!options.sequelize) {
      throw new Error('No Sequelize instance passed');
    }

Severity: Minor
Found in src/model.js - About 6 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 constructor has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

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

    if (this.options.through === undefined || this.options.through === true || this.options.through === null) {
      throw new AssociationError(
Severity: Minor
Found in src/associations/belongs-to-many.js - About 6 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 upsertQuery has a Cognitive Complexity of 40 (exceeds 5 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: Minor
Found in src/dialects/mssql/query-generator.js - About 6 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 update has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static async update(values, options) {
    options = Utils.cloneDeep(options);

    this._injectScope(options);
    this._optionsMustContainWhere(options);
Severity: Major
Found in src/model.js - About 6 hrs to fix

    Function constructor has 150 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(database, username, password, options) {
        let config;
    
        if (arguments.length === 1 && typeof database === 'object') {
          // new Sequelize({ ... options })
    Severity: Major
    Found in src/sequelize.js - About 6 hrs to fix

      Function refreshAttributes has 150 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static refreshAttributes() {
          const attributeManipulation = {};
      
          this.prototype._customGetters = {};
          this.prototype._customSetters = {};
      Severity: Major
      Found in src/model.js - About 6 hrs to fix

        Function get has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

          get(key, options) {
            if (options === undefined && typeof key === 'object') {
              options = key;
              key = undefined;
            }
        Severity: Minor
        Found in src/model.js - About 5 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

        File utils.js has 411 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const DataTypes = require('./data-types');
        const SqlString = require('./sql-string');
        const _ = require('lodash');
        const baseIsNative = require('lodash/_baseIsNative');
        const uuidv1 = require('uuid').v1;
        Severity: Minor
        Found in src/utils.js - About 5 hrs to fix

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

                if (value instanceof Utils.SequelizeMethod || options.bindParam === false) {
                  values.push(
                    `${this.quoteIdentifier(key)}=${this.escape(
                      value,
                      (modelAttributeMap && modelAttributeMap[key]) || undefined,
          Severity: Major
          Found in src/dialects/abstract/query-generator.js and 1 other location - About 5 hrs to fix
          src/dialects/sqlite/query-generator.js on lines 210..227

          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 152.

          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

              this.accessors = {
                get: `get${plural}`,
                set: `set${plural}`,
                addMultiple: `add${plural}`,
                add: `add${singular}`,
          Severity: Major
          Found in src/associations/has-many.js and 1 other location - About 5 hrs to fix
          src/associations/belongs-to-many.js on lines 215..226

          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 152.

          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

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

                if (value instanceof Utils.SequelizeMethod || options.bindParam === false) {
                  values.push(
                    `${this.quoteIdentifier(key)}=${this.escape(
                      value,
                      (modelAttributeMap && modelAttributeMap[key]) || undefined,
          Severity: Major
          Found in src/dialects/sqlite/query-generator.js and 1 other location - About 5 hrs to fix
          src/dialects/abstract/query-generator.js on lines 415..432

          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 152.

          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

              this.accessors = {
                get: `get${plural}`,
                set: `set${plural}`,
                addMultiple: `add${plural}`,
                add: `add${singular}`,
          Severity: Major
          Found in src/associations/belongs-to-many.js and 1 other location - About 5 hrs to fix
          src/associations/has-many.js on lines 91..102

          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 152.

          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

          File query-generator.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const Utils = require('../../utils');
          const Transaction = require('../../transaction');
          const _ = require('lodash');
          const MySqlQueryGenerator = require('../mysql/query-generator');
          const AbstractQueryGenerator = require('../abstract/query-generator');
          Severity: Minor
          Found in src/dialects/sqlite/query-generator.js - About 5 hrs to fix

            Function generateInclude has 141 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              generateInclude(include, parentTableName, topLevelInfo) {
                const joinQueries = {
                  mainQuery: [],
                  subQuery: []
                };
            Severity: Major
            Found in src/dialects/abstract/query-generator.js - About 5 hrs to fix

              Function formatResults has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                formatResults(data, rowCount) {
                  if (this.isInsertQuery(data)) {
                    this.handleInsertQuery(data);
                    return [this.instance || data, rowCount];
                  }
              Severity: Minor
              Found in src/dialects/mssql/query.js - About 5 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 generateJoin has a Cognitive Complexity of 37 (exceeds 5 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: Minor
              Found in src/dialects/abstract/query-generator.js - About 5 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 _validateIncludedElement has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                static _validateIncludedElement(include, tableNames, options) {
                  tableNames[include.model.getTableName()] = true;
              
                  if (include.attributes && !options.raw) {
                    include.model._expandAttributes(include);
              Severity: Minor
              Found in src/model.js - About 5 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 attributesToSQL has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
              Open

                attributesToSQL(attributes) {
                  const result = {};
                  for (const name in attributes) {
                    const dataType = attributes[name];
                    const fieldName = dataType.field || name;
              Severity: Minor
              Found in src/dialects/sqlite/query-generator.js - About 5 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

              File query.js has 399 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const _ = require('lodash');
              const Utils = require('../../utils');
              const AbstractQuery = require('../abstract/query');
              const QueryTypes = require('../../query-types');
              const sequelizeErrors = require('../../errors');
              Severity: Minor
              Found in src/dialects/sqlite/query.js - About 5 hrs to fix

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

                      if (this.instance && this.instance.dataValues) {
                        for (const key in rows[0]) {
                          if (Object.prototype.hasOwnProperty.call(rows[0], key)) {
                            const record = rows[0][key];
                
                
                Severity: Major
                Found in src/dialects/postgres/query.js and 1 other location - About 5 hrs to fix
                src/dialects/mssql/query.js on lines 405..418

                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 143.

                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