sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

    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

            Function ensureEnums has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
            Open

              async ensureEnums(tableName, attributes, options, model) {
                const keys = Object.keys(attributes);
                const keyLen = keys.length;
            
                let sql = '';
            Severity: Minor
            Found in src/dialects/postgres/query-interface.js - About 7 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

            PostgresQueryGenerator has 55 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class PostgresQueryGenerator extends AbstractQueryGenerator {
              setSearchPath(searchPath) {
                return `SET search_path to ${searchPath};`;
              }
            
            
            Severity: Major
            Found in src/dialects/postgres/query-generator.js - About 7 hrs to fix

              Function insertQuery has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

                insertQuery(table, valueHash, modelAttributes, options) {
                  options = options || {};
                  _.defaults(options, this.options);
              
                  const modelAttributeMap = {};
              Severity: Minor
              Found in src/dialects/abstract/query-generator.js - About 7 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 _expandIncludeAllElement has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

                static _expandIncludeAllElement(includes, include) {
                  // check 'all' attribute provided is valid
                  let all = include.all;
                  delete include.all;
              
              
              Severity: Minor
              Found in src/model.js - About 7 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 48 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor(database, username, password, options) {
                  let config;
              
                  if (arguments.length === 1 && typeof database === 'object') {
                    // new Sequelize({ ... options })
              Severity: Minor
              Found in src/sequelize.js - About 7 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 a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
              Open

                whereItemQuery(key, value, options = {}) {
                  if (value === undefined) {
                    throw new Error(`WHERE parameter "${key}" has invalid "undefined" value`);
                  }
              
              
              Severity: Minor
              Found in src/dialects/abstract/query-generator.js - About 7 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

              QueryInterface has 52 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class QueryInterface {
                constructor(sequelize, queryGenerator) {
                  this.sequelize = sequelize;
                  this.queryGenerator = queryGenerator;
                }
              Severity: Major
              Found in src/dialects/abstract/query-interface.js - About 7 hrs to fix

                Function _handleQueryResponse has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                Open

                  _handleQueryResponse(metaData, columnTypes, err, results) {
                    if (err) {
                      err.sql = this.sql;
                      throw this.formatError(err);
                    }
                Severity: Minor
                Found in src/dialects/sqlite/query.js - About 7 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 exports has 179 lines of code (exceeds 25 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: Major
                Found in src/dialects/mssql/data-types.js - About 7 hrs to fix

                  Function handleSequelizeMethod has a Cognitive Complexity of 46 (exceeds 5 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: Minor
                  Found in src/dialects/abstract/query-generator.js - About 7 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 exports has 175 lines of code (exceeds 25 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: Major
                  Found in src/dialects/sqlite/data-types.js - About 7 hrs to fix

                    Function attributeToSQL has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                    Open

                      attributeToSQL(attribute, options) {
                        if (!_.isPlainObject(attribute)) {
                          attribute = {
                            type: attribute
                          };
                    Severity: Minor
                    Found in src/dialects/postgres/query-generator.js - About 6 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-generator.js has 446 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    const _ = require('lodash');
                    const Utils = require('../../utils');
                    const AbstractQueryGenerator = require('../abstract/query-generator');
                    const util = require('util');
                    const Op = require('../../operators');
                    Severity: Minor
                    Found in src/dialects/mysql/query-generator.js - About 6 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language