sequelize/sequelize

View on GitHub

Showing 446 of 804 total issues

Function exports has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = BaseTypes => {
  BaseTypes.ABSTRACT.prototype.dialectTypes = 'https://mariadb.com/kb/en/library/resultset/#field-types';

  /**
   * types: [buffer_type, ...]
Severity: Major
Found in lib/dialects/mariadb/data-types.js - About 5 hrs to fix

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

    'use strict';
    
    const _ = require('lodash');
    const Utils = require('../../utils');
    const AbstractQueryGenerator = require('../abstract/query-generator');
    Severity: Minor
    Found in lib/dialects/mysql/query-generator.js - About 5 hrs to fix

      Function exports has 142 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 lib/dialects/mysql/data-types.js - About 5 hrs to fix

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

          constructor(database, username, password, options) {
            let config;
        
            if (arguments.length === 1 && typeof database === 'object') {
              // new Sequelize({ ... options })
        Severity: Major
        Found in lib/sequelize.js - About 5 hrs to fix

          Function exports has a Cognitive Complexity of 37 (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 lib/dialects/mysql/data-types.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 attributesToSQL has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

            attributesToSQL(attributes) {
              const result = {};
          
              for (const name in attributes) {
                const dataType = attributes[name];
          Severity: Minor
          Found in lib/dialects/sqlite/query-generator.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 a Cognitive Complexity of 37 (exceeds 5 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(`${source.name}.belongsToMany(${target.name}) requires through option, pass either a string or a model`);
          Severity: Minor
          Found in lib/associations/belongs-to-many.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

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

          'use strict';
          
          const _ = require('lodash');
          const Utils = require('../../utils');
          const logger = require('../../utils/logger');
          Severity: Minor
          Found in lib/dialects/sqlite/query.js - About 5 hrs to fix

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

              static _validateIncludedElement(include, tableNames, options) {
                tableNames[include.model.getTableName()] = true;
            
                if (include.attributes && !options.raw) {
                  include.model._expandAttributes(include);
            Severity: Minor
            Found in lib/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 _handleQueryResponse has 131 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _handleQueryResponse(metaData, columnTypes, benchmark, queryBegin, err, results) {
                debug(`executed(${this.database.uuid || 'default'}) : ${this.sql}`);
            
                if (benchmark) {
                  this.sequelize.log(`Executed (${this.database.uuid || 'default'}): ${this.sql}`, Date.now() - queryBegin, this.options);
            Severity: Major
            Found in lib/dialects/sqlite/query.js - About 5 hrs to fix

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

                generateInclude(include, parentTableName, topLevelInfo) {
                  const joinQueries = {
                    mainQuery: [],
                    subQuery: []
                  };
              Severity: Major
              Found in lib/dialects/abstract/query-generator.js - About 5 hrs to fix

                Function addIndexQuery has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                Open

                  addIndexQuery(tableName, attributes, options, rawTablename) {
                    options = options || {};
                
                    if (!Array.isArray(attributes)) {
                      options = attributes;
                Severity: Minor
                Found in lib/dialects/abstract/query-generator.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 124 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(`${source.name}.belongsToMany(${target.name}) requires through option, pass either a string or a model`);
                Severity: Major
                Found in lib/associations/belongs-to-many.js - About 4 hrs to fix

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

                  'use strict';
                  
                  const Utils = require('../../utils');
                  const util = require('util');
                  const Transaction = require('../../transaction');
                  Severity: Minor
                  Found in lib/dialects/sqlite/query-generator.js - About 4 hrs to fix

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

                      formatResults(data, rowCount) {
                        let result = this.instance;
                        if (this.isInsertQuery(data)) {
                          this.handleInsertQuery(data);
                    
                    
                    Severity: Minor
                    Found in lib/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 attributeToSQL has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                    Open

                      attributeToSQL(attribute, options) {
                        if (!_.isPlainObject(attribute)) {
                          attribute = {
                            type: attribute
                          };
                    Severity: Minor
                    Found in lib/dialects/postgres/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

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

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

                      Function bulkCreate has 119 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static bulkCreate(records, options = {}) {
                          if (!records.length) {
                            return Promise.resolve([]);
                          }
                      
                      
                      Severity: Major
                      Found in lib/model.js - About 4 hrs to fix

                        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 lib/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 handleSequelizeMethod has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                        Open

                          handleSequelizeMethod(smth, tableName, factory, options, prepend) {
                            let result;
                        
                            if (this.OperatorMap.hasOwnProperty(smth.comparator)) {
                              smth.comparator = this.OperatorMap[smth.comparator];
                        Severity: Minor
                        Found in lib/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

                        Severity
                        Category
                        Status
                        Source
                        Language