sequelize/sequelize

View on GitHub

Showing 787 of 787 total issues

Consider simplifying this complex logical expression.
Open

    if (topLevelInfo.subQuery && !include.subQuery && include.parent.subQuery && !parentIsTop) {
      // If we are minifying aliases and our JOIN target has been minified, we need to use the alias instead of the original column name
      const joinSource =
        this._getAliasForField(tableSource, `${tableSource}.${attrSource}`, topLevelInfo.options) ||
        `${tableSource}.${attrSource}`;
Severity: Major
Found in src/dialects/abstract/query-generator.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

              if (value instanceof Utils.SequelizeMethod || options.bindParam === false) {
                values.push(
                  this.escape(value, (modelAttributeMap && modelAttributeMap[key]) || undefined, { context: 'INSERT' })
                );
              } else {
    Severity: Major
    Found in src/dialects/abstract/query-generator.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      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 - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if (!tableName.schema && (options.schema || (!!model && model._schema))) {
              tableName = this.queryGenerator.addSchema({
                tableName,
                _schema: (!!model && model._schema) || options.schema
              });
        Severity: Major
        Found in src/dialects/abstract/query-interface.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                if (Object.prototype.hasOwnProperty.call(definition, 'unique') && definition.unique) {
                  let idxName;
                  if (typeof definition.unique === 'object' && Object.prototype.hasOwnProperty.call(definition.unique, 'name')) {
                    idxName = definition.unique.name;
                  } else if (typeof definition.unique === 'string') {
          Severity: Major
          Found in src/model.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if (
                  originalValue &&
                  !!value &&
                  (value === originalValue ||
                    (value instanceof Date && originalValue instanceof Date && value.getTime() === originalValue.getTime()))
            Severity: Major
            Found in src/data-types.js - About 40 mins to fix

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

                    this._dialect.supports.index.using === 1 && options.using ? `USING ${options.using}` : '',
              Severity: Minor
              Found in src/dialects/abstract/query-generator.js and 1 other location - About 40 mins to fix
              src/dialects/abstract/query-generator.js on lines 621..621

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

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

                  if (Object.prototype.hasOwnProperty.call(options, 'schema')) {
                    Target = Target.schema(options.schema, options.schemaDelimiter);
                  }
              Severity: Major
              Found in src/associations/belongs-to.js and 3 other locations - About 40 mins to fix
              src/associations/belongs-to-many.js on lines 485..487
              src/associations/has-many.js on lines 232..234
              src/associations/has-one.js on lines 142..144

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

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

                  if (Object.prototype.hasOwnProperty.call(options, 'schema')) {
                    model = model.schema(options.schema, options.schemaDelimiter);
                  }
              Severity: Major
              Found in src/associations/belongs-to-many.js and 3 other locations - About 40 mins to fix
              src/associations/belongs-to.js on lines 140..142
              src/associations/has-many.js on lines 232..234
              src/associations/has-one.js on lines 142..144

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

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

                  if (Object.prototype.hasOwnProperty.call(options, 'schema')) {
                    Target = Target.schema(options.schema, options.schemaDelimiter);
                  }
              Severity: Major
              Found in src/associations/has-one.js and 3 other locations - About 40 mins to fix
              src/associations/belongs-to-many.js on lines 485..487
              src/associations/belongs-to.js on lines 140..142
              src/associations/has-many.js on lines 232..234

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

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

                  if (Object.prototype.hasOwnProperty.call(options, 'schema')) {
                    Model = Model.schema(options.schema, options.schemaDelimiter);
                  }
              Severity: Major
              Found in src/associations/has-many.js and 3 other locations - About 40 mins to fix
              src/associations/belongs-to-many.js on lines 485..487
              src/associations/belongs-to.js on lines 140..142
              src/associations/has-one.js on lines 142..144

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

              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

                    this._dialect.supports.index.using === 2 && options.using ? `USING ${options.using}` : '',
              Severity: Minor
              Found in src/dialects/abstract/query-generator.js and 1 other location - About 40 mins to fix
              src/dialects/abstract/query-generator.js on lines 619..619

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

              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

                min(str: string, val: number): boolean {
                  const number = parseFloat(str);
                  return isNaN(number) || number >= val;
                },
              Severity: Minor
              Found in src/utils/validator-extras.ts and 1 other location - About 40 mins to fix
              src/utils/validator-extras.ts on lines 75..78

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

              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

                max(str: string, val: number): boolean {
                  const number = parseFloat(str);
                  return isNaN(number) || number <= val;
                },
              Severity: Minor
              Found in src/utils/validator-extras.ts and 1 other location - About 40 mins to fix
              src/utils/validator-extras.ts on lines 71..74

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

              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 addForeignKeyConstraints has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function addForeignKeyConstraints(newAttribute, source, target, options, key) {
              Severity: Minor
              Found in src/associations/helpers.js - About 35 mins to fix

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

                    if (typeof tableName === 'string') {
                      tableName = this.quoteIdentifiers(tableName);
                    } else {
                      tableName = this.quoteTable(tableName);
                    }
                Severity: Major
                Found in src/dialects/abstract/query-generator.js and 3 other locations - About 35 mins to fix
                src/dialects/abstract/query-generator.js on lines 599..603
                src/dialects/abstract/query-generator.js on lines 631..635
                src/dialects/abstract/query-generator.js on lines 2325..2329

                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

                      if (orders.mainQueryOrder.length) {
                        mainQueryItems.push(` ORDER BY ${orders.mainQueryOrder.join(', ')}`);
                      }
                Severity: Minor
                Found in src/dialects/abstract/query-generator.js and 1 other location - About 35 mins to fix
                src/dialects/abstract/query-generator.js on lines 1452..1454

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

                      if (typeof value === 'boolean') {
                        value = this.booleanValue(value);
                      } else {
                        value = this.escape(value);
                      }
                Severity: Major
                Found in src/dialects/abstract/query-generator.js and 3 other locations - About 35 mins to fix
                src/dialects/abstract/query-generator.js on lines 599..603
                src/dialects/abstract/query-generator.js on lines 631..635
                src/dialects/abstract/query-generator.js on lines 725..729

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

                    if (typeof tableName === 'string') {
                      tableName = this.quoteIdentifiers(tableName);
                    } else {
                      tableName = this.quoteTable(tableName);
                    }
                Severity: Major
                Found in src/dialects/abstract/query-generator.js and 3 other locations - About 35 mins to fix
                src/dialects/abstract/query-generator.js on lines 631..635
                src/dialects/abstract/query-generator.js on lines 725..729
                src/dialects/abstract/query-generator.js on lines 2325..2329

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

                    if (typeof tableName === 'string') {
                      tableName = this.quoteIdentifiers(tableName);
                    } else {
                      tableName = this.quoteTable(tableName);
                    }
                Severity: Major
                Found in src/dialects/abstract/query-generator.js and 3 other locations - About 35 mins to fix
                src/dialects/abstract/query-generator.js on lines 599..603
                src/dialects/abstract/query-generator.js on lines 725..729
                src/dialects/abstract/query-generator.js on lines 2325..2329

                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

                Severity
                Category
                Status
                Source
                Language