sequelize/sequelize

View on GitHub
src/dialects/mssql/query-generator.js

Summary

Maintainability
F
1 wk
Test Coverage

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

const _ = require('lodash');
const Utils = require('../../utils');
const DataTypes = require('../../data-types');
const TableHints = require('../../table-hints');
const AbstractQueryGenerator = require('../abstract/query-generator');
Severity: Major
Found in src/dialects/mssql/query-generator.js - About 1 day to fix

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

    class MSSQLQueryGenerator extends AbstractQueryGenerator {
      createDatabaseQuery(databaseName, options) {
        options = { collate: null, ...options };
    
        const collation = options.collate ? `COLLATE ${this.escape(options.collate)}` : '';
    Severity: Minor
    Found in src/dialects/mssql/query-generator.js - About 6 hrs to fix

      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 addLimitAndOffset has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        addLimitAndOffset(options, model) {
          // Skip handling of limit and offset as postfixes for older SQL Server versions
          if (
            semver.valid(this.sequelize.options.databaseVersion) &&
            semver.lt(this.sequelize.options.databaseVersion, '11.0.0')
      Severity: Minor
      Found in src/dialects/mssql/query-generator.js - About 4 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 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 attributeToSQL has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          attributeToSQL(attribute) {
            if (!_.isPlainObject(attribute)) {
              attribute = {
                type: attribute
              };
        Severity: Minor
        Found in src/dialects/mssql/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 createTableQuery has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          createTableQuery(tableName, attributes, options) {
            const primaryKeys = [],
              foreignKeys = {},
              attributesClauseParts = [];
        
        
        Severity: Minor
        Found in src/dialects/mssql/query-generator.js - About 2 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 attributeToSQL has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          attributeToSQL(attribute) {
            if (!_.isPlainObject(attribute)) {
              attribute = {
                type: attribute
              };
        Severity: Major
        Found in src/dialects/mssql/query-generator.js - About 2 hrs to fix

          Function createTableQuery has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            createTableQuery(tableName, attributes, options) {
              const primaryKeys = [],
                foreignKeys = {},
                attributesClauseParts = [];
          
          
          Severity: Major
          Found in src/dialects/mssql/query-generator.js - About 2 hrs to fix

            Function bulkInsertQuery has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              bulkInsertQuery(tableName, attrValueHashes, options, attributes) {
                const quotedTable = this.quoteTable(tableName);
                options = options || {};
                attributes = attributes || {};
            
            
            Severity: Major
            Found in src/dialects/mssql/query-generator.js - About 2 hrs to fix

              Function selectFromTableFragment has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                selectFromTableFragment(options, model, attributes, tables, mainTableAs, where) {
                  this._throwOnEmptyAttributes(attributes, {
                    modelName: model && model.name,
                    as: mainTableAs
                  });
              Severity: Minor
              Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

                Function addLimitAndOffset has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  addLimitAndOffset(options, model) {
                    // Skip handling of limit and offset as postfixes for older SQL Server versions
                    if (
                      semver.valid(this.sequelize.options.databaseVersion) &&
                      semver.lt(this.sequelize.options.databaseVersion, '11.0.0')
                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 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

                      Consider simplifying this complex logical expression.
                      Open

                          if (isSQLServer2008 && options.offset) {
                            // For earlier versions of SQL server, we need to nest several queries
                            // in order to emulate the OFFSET behavior.
                            //
                            // 1. The outermost query selects all items from the inner query block.
                      Severity: Critical
                      Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

                        Function attributesToSQL has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          attributesToSQL(attributes, options) {
                            const result = {},
                              existingConstraints = [];
                            let key, attribute;
                        
                        
                        Severity: Minor
                        Found in src/dialects/mssql/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 changeColumnQuery has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          changeColumnQuery(tableName, attributes) {
                            const attrString = [],
                              constraintString = [];
                            let commentString = '';
                        
                        
                        Severity: Minor
                        Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

                          Function bulkInsertQuery has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            bulkInsertQuery(tableName, attrValueHashes, options, attributes) {
                              const quotedTable = this.quoteTable(tableName);
                              options = options || {};
                              attributes = attributes || {};
                          
                          
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js - About 55 mins 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 selectFromTableFragment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            selectFromTableFragment(options, model, attributes, tables, mainTableAs, where) {
                              this._throwOnEmptyAttributes(attributes, {
                                modelName: model && model.name,
                                as: mainTableAs
                              });
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js - About 45 mins 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 changeColumnQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            changeColumnQuery(tableName, attributes) {
                              const attrString = [],
                                constraintString = [];
                              let commentString = '';
                          
                          
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js - About 35 mins 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

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

                                  if (dataType.includes('PRIMARY KEY')) {
                                    primaryKeys.push(attr);
                          
                                    if (dataType.includes('REFERENCES')) {
                                      // MSSQL doesn't support inline REFERENCES declarations: move to the end
                          Severity: Major
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 1 day to fix
                          src/dialects/mysql/query-generator.js on lines 87..105

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

                          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 (dataType.includes('COMMENT ')) {
                                    const commentMatch = dataType.match(/^(.+) (COMMENT.*)$/);
                                    const commentText = commentMatch[2].replace('COMMENT', '').trim();
                                    commentStr += this.commentTemplate(commentText, tableName, attr);
                                    // remove comment related substring from dataType
                          Severity: Major
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 2 hrs to fix
                          src/dialects/mssql/query-generator.js on lines 308..314

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

                          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 (definition.includes('COMMENT ')) {
                                  const commentMatch = definition.match(/^(.+) (COMMENT.*)$/);
                                  const commentText = commentMatch[2].replace('COMMENT', '').trim();
                                  commentString += this.commentTemplate(commentText, tableName, attributeName);
                                  // remove comment related substring from dataType
                          Severity: Major
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 2 hrs to fix
                          src/dialects/mssql/query-generator.js on lines 134..140

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

                          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 (attribute.references.key) {
                                  template += ` (${this.quoteIdentifier(attribute.references.key)})`;
                                } else {
                                  template += ` (${this.quoteIdentifier('id')})`;
                                }
                          Severity: Major
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 2 hrs to fix
                          src/dialects/mysql/query-generator.js on lines 404..408

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

                          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

                                      `CONSTRAINT ${this.quoteIdentifier(indexName)} UNIQUE (${columns.fields
                                        .map(field => this.quoteIdentifier(field))
                                        .join(', ')})`
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 55 mins to fix
                          src/dialects/mysql/query-generator.js on lines 118..120

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

                          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

                            startTransactionQuery(transaction) {
                              if (transaction.parent) {
                                return `SAVE TRANSACTION ${this.quoteIdentifier(transaction.name)};`;
                              }
                          
                          
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 35 mins to fix
                          src/dialects/mssql/query-generator.js on lines 840..846

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

                          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

                            rollbackTransactionQuery(transaction) {
                              if (transaction.parent) {
                                return `ROLLBACK TRANSACTION ${this.quoteIdentifier(transaction.name)};`;
                              }
                          
                          
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 35 mins to fix
                          src/dialects/mssql/query-generator.js on lines 824..830

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

                          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 3 locations. Consider refactoring.
                          Open

                                if (model.rawAttributes[key].unique) {
                                  uniqueAttrs.push(model.rawAttributes[key].field || key);
                                }
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 2 other locations - About 35 mins to fix
                          src/dialects/mssql/query-generator.js on lines 431..433
                          src/dialects/mssql/query-generator.js on lines 437..439

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

                          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 3 locations. Consider refactoring.
                          Open

                                if (model.rawAttributes[key].primaryKey) {
                                  primaryKeysAttrs.push(model.rawAttributes[key].field || key);
                                }
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 2 other locations - About 35 mins to fix
                          src/dialects/mssql/query-generator.js on lines 434..436
                          src/dialects/mssql/query-generator.js on lines 437..439

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

                          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 3 locations. Consider refactoring.
                          Open

                                if (model.rawAttributes[key].autoIncrement) {
                                  identityAttrs.push(model.rawAttributes[key].field || key);
                                }
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 2 other locations - About 35 mins to fix
                          src/dialects/mssql/query-generator.js on lines 431..433
                          src/dialects/mssql/query-generator.js on lines 434..436

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

                          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 (typeof indexName !== 'string') {
                                      indexName = `uniq_${tableName}_${columns.fields.join('_')}`;
                                    }
                          Severity: Minor
                          Found in src/dialects/mssql/query-generator.js and 1 other location - About 30 mins to fix
                          src/dialects/mysql/query-generator.js on lines 115..117

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status