sequelize/sequelize

View on GitHub

Showing 787 of 787 total issues

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

const util = require('util');
const _ = require('lodash');
const wkx = require('wkx');
const sequelizeErrors = require('./errors');
const Validator = require('./utils/validator-extras').validator;
Severity: Major
Found in src/data-types.js - About 1 day to fix

    Function selectQuery has 282 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      selectQuery(tableName, options, model) {
        options = options || {};
        const limit = options.limit;
        const mainQueryItems = [];
        const subQueryItems = [];
    Severity: Major
    Found in src/dialects/abstract/query-generator.js - About 1 day to fix

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

      const _ = require('lodash');
      
      const Utils = require('../../utils');
      const DataTypes = require('../../data-types');
      const Transaction = require('../../transaction');
      Severity: Major
      Found in src/dialects/abstract/query-interface.js - About 1 day to fix

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

            if (smth instanceof Utils.Json) {
              // Parse nested object
              if (smth.conditions) {
                const conditions = this.parseConditionObject(smth.conditions).map(
                  condition =>
        Severity: Major
        Found in src/dialects/postgres/query-generator.js and 1 other location - About 1 day to fix
        src/dialects/mysql/query-generator.js on lines 232..272

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

        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 (smth instanceof Utils.Json) {
              // Parse nested object
              if (smth.conditions) {
                const conditions = this.parseConditionObject(smth.conditions).map(
                  condition =>
        Severity: Major
        Found in src/dialects/mysql/query-generator.js and 1 other location - About 1 day to fix
        src/dialects/postgres/query-generator.js on lines 220..249

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

        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 _groupJoinData has 265 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static _groupJoinData(rows, includeOptions, options) {
            /*
             * Assumptions
             * ID is not necessarily the first field
             * All fields for a level is grouped in the same set (i.e. Panel.id, Task.id, Panel.title is not possible)
        Severity: Major
        Found in src/dialects/abstract/query.js - About 1 day to fix

          File belongs-to-many.js has 594 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const Utils = require('./../utils');
          const Helpers = require('./helpers');
          const _ = require('lodash');
          const Association = require('./base');
          const BelongsTo = require('./belongs-to');
          Severity: Major
          Found in src/associations/belongs-to-many.js - About 1 day to fix

            Function save has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
            Open

              async save(options) {
                if (arguments.length > 1) {
                  throw new Error('The second argument was removed in favor of the options object.');
                }
            
            
            Severity: Minor
            Found in src/model.js - About 1 day to fix

            Cognitive Complexity

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

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

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

            Further reading

            File sequelize.js has 580 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const url = require('url');
            const path = require('path');
            const retry = require('retry-as-promised');
            const _ = require('lodash');
            
            
            Severity: Major
            Found in src/sequelize.js - About 1 day to fix

              Function sync has a Cognitive Complexity of 63 (exceeds 5 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: Minor
              Found in src/model.js - About 1 day 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

                  while (currentIndex < stmt.length) {
                    const string = stmt.substr(currentIndex);
                    const functionMatches = jsonFunctionRegex.exec(string);
                    if (functionMatches) {
                      currentIndex += functionMatches[0].indexOf('(');
              Severity: Major
              Found in src/dialects/postgres/query-generator.js and 1 other location - About 1 day to fix
              src/dialects/mysql/query-generator.js on lines 452..484

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

              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

                  while (currentIndex < stmt.length) {
                    const string = stmt.substr(currentIndex);
                    const functionMatches = JSON_FUNCTION_REGEX.exec(string);
                    if (functionMatches) {
                      currentIndex += functionMatches[0].indexOf('(');
              Severity: Major
              Found in src/dialects/mysql/query-generator.js and 1 other location - About 1 day to fix
              src/dialects/postgres/query-generator.js on lines 175..207

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

              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 save has 228 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async save(options) {
                  if (arguments.length > 1) {
                    throw new Error('The second argument was removed in favor of the options object.');
                  }
              
              
              Severity: Major
              Found in src/model.js - About 1 day to fix

                Function bulkCreate has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
                Open

                  static async bulkCreate(records, options = {}) {
                    if (!records.length) {
                      return [];
                    }
                
                
                Severity: Minor
                Found in src/model.js - About 1 day to fix

                Cognitive Complexity

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

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

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

                Further reading

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

                const _ = require('lodash');
                const SqlString = require('../../sql-string');
                const QueryTypes = require('../../query-types');
                const Dot = require('dottie');
                const deprecations = require('../../utils/deprecations');
                Severity: Major
                Found in src/dialects/abstract/query.js - About 1 day to fix

                  Function run has 218 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async run(sql, parameters) {
                      const { connection } = this;
                  
                      if (!_.isEmpty(this.options.searchPath)) {
                        sql = this.sequelize.getQueryInterface().queryGenerator.setSearchPath(this.options.searchPath) + sql;
                  Severity: Major
                  Found in src/dialects/postgres/query.js - About 1 day to fix

                    QueryGenerator has 60 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class QueryGenerator {
                      constructor(options) {
                        if (!options.sequelize) throw new Error('QueryGenerator initialized without options.sequelize');
                        if (!options._dialect) throw new Error('QueryGenerator initialized without options._dialect');
                    
                    
                    Severity: Major
                    Found in src/dialects/abstract/query-generator.js - About 1 day to fix

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

                      class GEOMETRY extends ABSTRACT {
                        /**
                         * @param {string} [type] Type of geometry data
                         * @param {string} [srid] SRID of type
                         */
                      Severity: Major
                      Found in src/data-types.js and 1 other location - About 1 day to fix
                      src/data-types.js on lines 863..881

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

                      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

                      class GEOGRAPHY extends ABSTRACT {
                        /**
                         * @param {string} [type] Type of geography data
                         * @param {string} [srid] SRID of type
                         */
                      Severity: Major
                      Found in src/data-types.js and 1 other location - About 1 day to fix
                      src/data-types.js on lines 820..838

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

                      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 (instance[include.association.through.model.name]) {
                                          for (const attr of Object.keys(include.association.through.model.rawAttributes)) {
                                            if (
                                              include.association.through.model.rawAttributes[attr]._autoGenerated ||
                                              attr === include.association.foreignKey ||
                      Severity: Major
                      Found in src/model.js and 1 other location - About 1 day to fix
                      src/model.js on lines 2942..2954

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

                      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