sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

module.exports = BaseTypes => {
  const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'https://www.sqlite.org/datatype3.html');

  /**
   * Removes unsupported SQLite options, i.e., UNSIGNED and ZEROFILL, for the integer data types.
Severity: Minor
Found in src/dialects/sqlite/data-types.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 set has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  set(key, value, options) {
    let values;
    let originalValue;

    if (typeof key === 'object' && key !== null) {
Severity: Major
Found in src/model.js - About 4 hrs to fix

    Function exports has 105 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 src/dialects/mariadb/data-types.js - About 4 hrs to fix

      Function _injectAttributes has 105 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _injectAttributes() {
          this.identifier = this.foreignKey;
          this.foreignIdentifier = this.otherKey;
      
          // remove any PKs previously defined by sequelize
      Severity: Major
      Found in src/associations/belongs-to-many.js - About 4 hrs to fix

        Function _validateIncludedElement has 103 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static _validateIncludedElement(include, tableNames, options) {
            tableNames[include.model.getTableName()] = true;
        
            if (include.attributes && !options.raw) {
              include.model._expandAttributes(include);
        Severity: Major
        Found in src/model.js - About 4 hrs to fix

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

          module.exports = BaseTypes => {
            const warn = BaseTypes.ABSTRACT.warn.bind(
              undefined,
              'https://msdn.microsoft.com/en-us/library/ms187752%28v=sql.110%29.aspx'
            );
          Severity: Minor
          Found in src/dialects/mssql/data-types.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 addLimitAndOffset has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

            addLimitAndOffset(options, model) {
              // Skip handling of limit and offset as postfixes for older SQL Server versions
              if (
                semver.valid(this.sequelize.options.databaseVersion) &&
                semver.lt(this.sequelize.options.databaseVersion, '11.0.0')
          Severity: Minor
          Found in src/dialects/mssql/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 ensureEnums has 101 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async ensureEnums(tableName, attributes, options, model) {
              const keys = Object.keys(attributes);
              const keyLen = keys.length;
          
              let sql = '';
          Severity: Major
          Found in src/dialects/postgres/query-interface.js - About 4 hrs to fix

            Function connect has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

              async connect(config) {
                config.user = config.username;
                const connectionConfig = _.pick(config, ['user', 'password', 'host', 'database', 'port']);
            
                connectionConfig.types = {
            Severity: Minor
            Found in src/dialects/postgres/connection-manager.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 connect has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

              async connect(config) {
                const connectionConfig = {
                  server: config.host,
                  authentication: {
                    type: 'default',
            Severity: Minor
            Found in src/dialects/mssql/connection-manager.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 whereItemQuery has 95 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              whereItemQuery(key, value, options = {}) {
                if (value === undefined) {
                  throw new Error(`WHERE parameter "${key}" has invalid "undefined" value`);
                }
            
            
            Severity: Major
            Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

              File has-many.js has 324 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 Op = require('../operators');
              Severity: Minor
              Found in src/associations/has-many.js - About 3 hrs to fix

                Function attributeToSQL has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  attributeToSQL(attribute, options) {
                    if (!_.isPlainObject(attribute)) {
                      attribute = {
                        type: attribute
                      };
                Severity: Major
                Found in src/dialects/postgres/query-generator.js - About 3 hrs to fix

                  Function connect has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async connect(config) {
                      const connectionConfig = {
                        server: config.host,
                        authentication: {
                          type: 'default',
                  Severity: Major
                  Found in src/dialects/mssql/connection-manager.js - About 3 hrs to fix

                    Function query has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async query(sql, options) {
                        options = { ...this.options.query, ...options };
                    
                        if (options.instance && !options.model) {
                          options.model = options.instance.constructor;
                    Severity: Major
                    Found in src/sequelize.js - About 3 hrs to fix

                      Function _generateSubQueryFilter has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _generateSubQueryFilter(include, includeAs, topLevelInfo) {
                          if (!topLevelInfo.subQuery || !include.subQueryFilter) {
                            return;
                          }
                      
                      
                      Severity: Major
                      Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

                        Function formatError has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                          formatError(err) {
                            switch (err.errno) {
                              case ER_DUP_ENTRY: {
                                const match = err.message.match(/Duplicate entry '([\s\S]*)' for key '?((.|\s)*?)'?\s.*$/);
                        
                        
                        Severity: Minor
                        Found in src/dialects/mariadb/query.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 getWhereConditions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                          getWhereConditions(smth, tableName, factory, options, prepend) {
                            const where = {};
                        
                            if (Array.isArray(tableName)) {
                              tableName = tableName[0];
                        Severity: Minor
                        Found in src/dialects/abstract/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 formatError has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                          formatError(err) {
                            const errCode = err.errno || err.code;
                        
                            switch (errCode) {
                              case 1062: {
                        Severity: Minor
                        Found in src/dialects/mysql/query.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 findOrCreate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                          static async findOrCreate(options) {
                            if (!options || !options.where || arguments.length > 1) {
                              throw new Error(
                                'Missing where attribute in the options parameter passed to findOrCreate. ' +
                                  'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
                        Severity: Minor
                        Found in src/model.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

                        Severity
                        Category
                        Status
                        Source
                        Language