sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function _conformInclude has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  static _conformInclude(include, self) {
    if (include) {
      let model;

      if (include._pseudo) return include;
Severity: Minor
Found in src/model.js - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function constructor has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(source, target, options) {
    super(source, target, options);

    if (this.options.through === undefined || this.options.through === true || this.options.through === null) {
      throw new AssociationError(
Severity: Major
Found in src/associations/belongs-to-many.js - About 5 hrs to fix

    Function _handleQueryResponse has 129 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _handleQueryResponse(metaData, columnTypes, err, results) {
        if (err) {
          err.sql = this.sql;
          throw this.formatError(err);
        }
    Severity: Major
    Found in src/dialects/sqlite/query.js - About 5 hrs to fix

      Function insertQuery has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        insertQuery(table, valueHash, modelAttributes, options) {
          options = options || {};
          _.defaults(options, this.options);
      
          const modelAttributeMap = {};
      Severity: Major
      Found in src/dialects/abstract/query-generator.js - About 5 hrs to fix

        Function init has 126 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static init(attributes, options = {}) {
            if (!options.sequelize) {
              throw new Error('No Sequelize instance passed');
            }
        
        
        Severity: Major
        Found in src/model.js - About 5 hrs to fix

          Function formatResults has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

            formatResults(data) {
              let result = this.instance;
          
              if (this.isBulkUpdateQuery() || this.isBulkDeleteQuery()) {
                return data.affectedRows;
          Severity: Minor
          Found in src/dialects/mariadb/query.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 _whereParseSingleValueObject has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

            _whereParseSingleValueObject(key, field, prop, value, options) {
              if (prop === Op.not) {
                if (Array.isArray(value)) {
                  prop = Op.notIn;
                } else if (value !== null && value !== true && value !== false) {
          Severity: Minor
          Found in src/dialects/abstract/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 createTableQuery has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
          Open

            createTableQuery(tableName, attributes, options) {
              options = options || {};
          
              const primaryKeys = [];
              const needsMultiplePrimaryKeys =
          Severity: Minor
          Found in src/dialects/sqlite/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 generateThroughJoin has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

            generateThroughJoin(include, includeAs, parentTableName, topLevelInfo) {
              const through = include.through;
              const throughTable = through.model.getTableName();
              const throughAs = `${includeAs.internalAs}->${through.as}`;
              const externalThroughAs = `${includeAs.externalAs}.${through.as}`;
          Severity: Minor
          Found in src/dialects/abstract/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 formatResults has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

            formatResults(data) {
              let result = this.instance;
          
              if (this.isInsertQuery(data)) {
                this.handleInsertQuery(data);
          Severity: Minor
          Found in src/dialects/mysql/query.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 quote has 117 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            quote(collection, parent, connector) {
              // init
              const validOrderOptions = [
                'ASC',
                'DESC',
          Severity: Major
          Found in src/dialects/abstract/query-generator.js - About 4 hrs to fix

            Sequelize has 36 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Sequelize {
              /**
               * Instantiate sequelize with name of database, username and password.
               *
               * @example
            Severity: Minor
            Found in src/sequelize.js - About 4 hrs to fix

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

              const AbstractQuery = require('../abstract/query');
              const QueryTypes = require('../../query-types');
              const sequelizeErrors = require('../../errors');
              const _ = require('lodash');
              const { logger } = require('../../utils/logger');
              Severity: Minor
              Found in src/dialects/postgres/query.js - About 4 hrs to fix

                Function _run has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                  async _run(connection, sql, parameters) {
                    this.sql = sql;
                    const { options } = this;
                
                    const complete = this._logQuery(sql, debug, parameters);
                Severity: Minor
                Found in src/dialects/mssql/query.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 _validateIncludedElements has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                  static _validateIncludedElements(options, tableNames) {
                    if (!options.model) options.model = this;
                
                    tableNames = tableNames || {};
                    options.includeNames = [];
                Severity: Minor
                Found in src/model.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 connect has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async connect(config) {
                    config.user = config.username;
                    const connectionConfig = _.pick(config, ['user', 'password', 'host', 'database', 'port']);
                
                    connectionConfig.types = {
                Severity: Major
                Found in src/dialects/postgres/connection-manager.js - About 4 hrs to fix

                  Function generateThroughJoin has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    generateThroughJoin(include, includeAs, parentTableName, topLevelInfo) {
                      const through = include.through;
                      const throughTable = through.model.getTableName();
                      const throughAs = `${includeAs.internalAs}->${through.as}`;
                      const externalThroughAs = `${includeAs.externalAs}.${through.as}`;
                  Severity: Major
                  Found in src/dialects/abstract/query-generator.js - About 4 hrs to fix

                    Function exports has 113 lines of code (exceeds 25 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: Major
                    Found in src/dialects/mysql/data-types.js - About 4 hrs to fix

                      Function _whereParseSingleValueObject has 113 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _whereParseSingleValueObject(key, field, prop, value, options) {
                          if (prop === Op.not) {
                            if (Array.isArray(value)) {
                              prop = Op.notIn;
                            } else if (value !== null && value !== true && value !== false) {
                      Severity: Major
                      Found in src/dialects/abstract/query-generator.js - About 4 hrs to fix

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

                        const AbstractQuery = require('../abstract/query');
                        const sequelizeErrors = require('../../errors');
                        const parserStore = require('../parserStore')('mssql');
                        const _ = require('lodash');
                        const { logger } = require('../../utils/logger');
                        Severity: Minor
                        Found in src/dialects/mssql/query.js - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language