sequelize/sequelize

View on GitHub

Showing 746 of 746 total issues

Function whereItemQuery has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

  whereItemQuery(key, value, options = {}) {
    if (value === undefined) {
      throw new Error(`WHERE parameter "${key}" has invalid "undefined" value`);
    }

Severity: Minor
Found in lib/dialects/abstract/query-generator.js - About 7 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 run has 183 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    if (!_.isEmpty(this.options.searchPath)) {
      sql = this.sequelize.getQueryInterface().QueryGenerator.setSearchPath(this.options.searchPath) + sql;
Severity: Major
Found in lib/dialects/postgres/query.js - About 7 hrs to fix

    Function _handleQueryResponse has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

      _handleQueryResponse(metaData, columnTypes, err, results) {
        if (err) {
          err.sql = this.sql;
          throw this.formatError(err);
        }
    Severity: Minor
    Found in lib/dialects/sqlite/query.js - About 7 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 exports has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = BaseTypes => {
      const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'https://msdn.microsoft.com/en-us/library/ms187752%28v=sql.110%29.aspx');
    
      /**
       * Removes unsupported MSSQL options, i.e., LENGTH, UNSIGNED and ZEROFILL, for the integer data types.
    Severity: Major
    Found in lib/dialects/mssql/data-types.js - About 7 hrs to fix

      Function exports has 175 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = BaseTypes => {
        const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'https://www.sqlite.org/datatype3.html');
      
        /**
         * Removes unsupported SQLite options, i.e., UNSIGNED and ZEROFILL, for the integer data types.
      Severity: Major
      Found in lib/dialects/sqlite/data-types.js - About 7 hrs to fix

        File data-types.js has 438 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        const _ = require('lodash');
        const wkx = require('wkx');
        
        
        Severity: Minor
        Found in lib/dialects/postgres/data-types.js - About 6 hrs to fix

          MSSQLQueryGenerator has 47 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class MSSQLQueryGenerator extends AbstractQueryGenerator {
            createDatabaseQuery(databaseName, options) {
              options = Object.assign({
                collate: null
              }, options || {});
          Severity: Minor
          Found in lib/dialects/mssql/query-generator.js - About 6 hrs to fix

            Function update has 155 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static update(values, options) {
                options = Utils.cloneDeep(options);
            
                this._injectScope(options);
                this._optionsMustContainWhere(options);
            Severity: Major
            Found in lib/model.js - About 6 hrs to fix

              Function updateQuery has a Cognitive Complexity of 40 (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 lib/dialects/abstract/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 get has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
              Open

                get(key, options) {
                  if (options === undefined && typeof key === 'object') {
                    options = key;
                    key = undefined;
                  }
              Severity: Minor
              Found in lib/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 refreshAttributes has 149 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function upsertQuery has a Cognitive Complexity of 39 (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 lib/dialects/mssql/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 formatResults has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                  formatResults(data, rowCount) {
                    let result = this.instance;
                    if (this.isInsertQuery(data)) {
                      this.handleInsertQuery(data);
                
                
                Severity: Minor
                Found in lib/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

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

                'use strict';
                
                const DataTypes = require('./data-types');
                const SqlString = require('./sql-string');
                const _ = require('lodash');
                Severity: Minor
                Found in lib/utils.js - About 5 hrs to fix

                  Identical 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, { context: 'UPDATE' })}`);
                        } else {
                          values.push(`${this.quoteIdentifier(key)}=${this.format(value, modelAttributeMap && modelAttributeMap[key] || undefined, { context: 'UPDATE' }, bindParam)}`);
                        }
                  Severity: Major
                  Found in lib/dialects/abstract/query-generator.js and 1 other location - About 5 hrs to fix
                  lib/dialects/sqlite/query-generator.js on lines 241..245

                  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 lib/associations/has-many.js and 1 other location - About 5 hrs to fix
                  lib/associations/belongs-to-many.js on lines 207..218

                  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 lib/associations/belongs-to-many.js and 1 other location - About 5 hrs to fix
                  lib/associations/has-many.js on lines 98..109

                  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

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

                  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 (options.uniqueKeys) {
                        _.each(options.uniqueKeys, (columns, indexName) => {
                          if (columns.customIndex) {
                            if (typeof indexName !== 'string') {
                              indexName = `uniq_${tableName}_${columns.fields.join('_')}`;
                  Severity: Major
                  Found in lib/dialects/mysql/query-generator.js and 1 other location - About 5 hrs to fix
                  lib/dialects/mssql/query-generator.js on lines 156..165

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

                  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 (options.uniqueKeys) {
                        _.each(options.uniqueKeys, (columns, indexName) => {
                          if (columns.customIndex) {
                            if (typeof indexName !== 'string') {
                              indexName = `uniq_${tableName}_${columns.fields.join('_')}`;
                  Severity: Major
                  Found in lib/dialects/mssql/query-generator.js and 1 other location - About 5 hrs to fix
                  lib/dialects/mysql/query-generator.js on lines 114..123

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

                  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