sequelize/sequelize

View on GitHub

Showing 787 of 787 total issues

Function addIndexQuery has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  addIndexQuery(tableName, attributes, options, rawTablename) {
    options = options || {};

    if (!Array.isArray(attributes)) {
      options = attributes;
Severity: Major
Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

    Function handleSequelizeMethod has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      handleSequelizeMethod(smth, tableName, factory, options, prepend) {
        let result;
    
        if (Object.prototype.hasOwnProperty.call(this.OperatorMap, smth.comparator)) {
          smth.comparator = this.OperatorMap[smth.comparator];
    Severity: Major
    Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

      Function exports has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = BaseTypes => {
        BaseTypes.ABSTRACT.prototype.dialectTypes = 'https://dev.mysql.com/doc/refman/5.7/en/data-types.html';
      
        /**
         * types: [buffer_type, ...]
      Severity: Minor
      Found in src/dialects/mysql/data-types.js - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function set has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        async set(sourceInstance, newAssociatedObjects, options) {
          options = options || {};
      
          const sourceKey = this.sourceKey;
          const targetKey = this.targetKey;
      Severity: Minor
      Found in src/associations/belongs-to-many.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 _injectAttributes has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        _injectAttributes() {
          this.identifier = this.foreignKey;
          this.foreignIdentifier = this.otherKey;
      
          // remove any PKs previously defined by sequelize
      Severity: Minor
      Found in src/associations/belongs-to-many.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 sync has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static async sync(options) {
          options = { ...this.options, ...options };
          options.hooks = options.hooks === undefined ? true : !!options.hooks;
      
          const attributes = this.tableAttributes;
      Severity: Major
      Found in src/model.js - About 3 hrs to fix

        Function _expandIncludeAllElement has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static _expandIncludeAllElement(includes, include) {
            // check 'all' attribute provided is valid
            let all = include.all;
            delete include.all;
        
        
        Severity: Major
        Found in src/model.js - About 3 hrs to fix

          Function add has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async add(sourceInstance, newInstances, options) {
              // If newInstances is null or undefined, no-op
              if (!newInstances) return Promise.resolve();
          
              options = { ...options };
          Severity: Major
          Found in src/associations/belongs-to-many.js - About 3 hrs to fix

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

              async increment(model, tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options) {
                options = Utils.cloneDeep(options);
            
                const sql = this.queryGenerator.arithmeticQuery(
                  '+',
            Severity: Major
            Found in src/dialects/abstract/query-interface.js and 1 other location - About 3 hrs to fix
            src/dialects/abstract/query-interface.js on lines 1000..1016

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

            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

              async decrement(model, tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options) {
                options = Utils.cloneDeep(options);
            
                const sql = this.queryGenerator.arithmeticQuery(
                  '-',
            Severity: Major
            Found in src/dialects/abstract/query-interface.js and 1 other location - About 3 hrs to fix
            src/dialects/abstract/query-interface.js on lines 982..998

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

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

              _sanitize(value) {
                if (value !== null && value !== undefined) {
                  if (Buffer.isBuffer(value) && value.length === 1) {
                    // Bit fields are returned as buffers
                    value = value[0];
            Severity: Minor
            Found in src/data-types.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 add has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

              async add(sourceInstance, newInstances, options) {
                // If newInstances is null or undefined, no-op
                if (!newInstances) return Promise.resolve();
            
                options = { ...options };
            Severity: Minor
            Found in src/associations/belongs-to-many.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

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

                  if (value[Op.any]) {
                    escapeOptions.isList = true;
                    return this._joinKeyValue(
                      key,
                      `(${this.escape(value[Op.any], field, escapeOptions)})`,
            Severity: Major
            Found in src/dialects/abstract/query-generator.js and 1 other location - About 3 hrs to fix
            src/dialects/abstract/query-generator.js on lines 2832..2840

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

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

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

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

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

            Refactorings

            Further Reading

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

                  if (value[Op.all]) {
                    escapeOptions.isList = true;
                    return this._joinKeyValue(
                      key,
                      `(${this.escape(value[Op.all], field, escapeOptions)})`,
            Severity: Major
            Found in src/dialects/abstract/query-generator.js and 1 other location - About 3 hrs to fix
            src/dialects/abstract/query-generator.js on lines 2823..2831

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

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

            class MssqlDialect extends AbstractDialect {
              constructor(sequelize) {
                super();
                this.sequelize = sequelize;
                this.connectionManager = new ConnectionManager(this, sequelize);
            Severity: Major
            Found in src/dialects/mssql/index.js and 4 other locations - About 3 hrs to fix
            src/dialects/mariadb/index.js on lines 9..20
            src/dialects/mysql/index.js on lines 9..20
            src/dialects/postgres/index.js on lines 9..20
            src/dialects/sqlite/index.js on lines 9..21

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

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

            class MysqlDialect extends AbstractDialect {
              constructor(sequelize) {
                super();
                this.sequelize = sequelize;
                this.connectionManager = new ConnectionManager(this, sequelize);
            Severity: Major
            Found in src/dialects/mysql/index.js and 4 other locations - About 3 hrs to fix
            src/dialects/mariadb/index.js on lines 9..20
            src/dialects/mssql/index.js on lines 9..20
            src/dialects/postgres/index.js on lines 9..20
            src/dialects/sqlite/index.js on lines 9..21

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

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

            class SqliteDialect extends AbstractDialect {
              constructor(sequelize) {
                super();
                this.sequelize = sequelize;
                this.connectionManager = new ConnectionManager(this, sequelize);
            Severity: Major
            Found in src/dialects/sqlite/index.js and 4 other locations - About 3 hrs to fix
            src/dialects/mariadb/index.js on lines 9..20
            src/dialects/mssql/index.js on lines 9..20
            src/dialects/mysql/index.js on lines 9..20
            src/dialects/postgres/index.js on lines 9..20

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

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

            class PostgresDialect extends AbstractDialect {
              constructor(sequelize) {
                super();
                this.sequelize = sequelize;
                this.connectionManager = new ConnectionManager(this, sequelize);
            Severity: Major
            Found in src/dialects/postgres/index.js and 4 other locations - About 3 hrs to fix
            src/dialects/mariadb/index.js on lines 9..20
            src/dialects/mssql/index.js on lines 9..20
            src/dialects/mysql/index.js on lines 9..20
            src/dialects/sqlite/index.js on lines 9..21

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

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

            class MariadbDialect extends AbstractDialect {
              constructor(sequelize) {
                super();
                this.sequelize = sequelize;
                this.connectionManager = new ConnectionManager(this, sequelize);
            Severity: Major
            Found in src/dialects/mariadb/index.js and 4 other locations - About 3 hrs to fix
            src/dialects/mssql/index.js on lines 9..20
            src/dialects/mysql/index.js on lines 9..20
            src/dialects/postgres/index.js on lines 9..20
            src/dialects/sqlite/index.js on lines 9..21

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

            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