sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

const _ = require('lodash');
const wkx = require('wkx');

module.exports = BaseTypes => {
  const warn = BaseTypes.ABSTRACT.warn.bind(undefined, 'http://www.postgresql.org/docs/9.4/static/datatype.html');
Severity: Minor
Found in src/dialects/postgres/data-types.js - About 6 hrs to fix

    MSSQLQueryGenerator has 47 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MSSQLQueryGenerator extends AbstractQueryGenerator {
      createDatabaseQuery(databaseName, options) {
        options = { collate: null, ...options };
    
        const collation = options.collate ? `COLLATE ${this.escape(options.collate)}` : '';
    Severity: Minor
    Found in src/dialects/mssql/query-generator.js - About 6 hrs to fix

      Function update has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

        static async update(values, options) {
          options = Utils.cloneDeep(options);
      
          this._injectScope(options);
          this._optionsMustContainWhere(options);
      Severity: Minor
      Found in src/model.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

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

        addIndexQuery(tableName, attributes, options, rawTablename) {
          options = options || {};
      
          if (!Array.isArray(attributes)) {
            options = attributes;
      Severity: Minor
      Found in src/dialects/abstract/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

      Function init has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

        static init(attributes, options = {}) {
          if (!options.sequelize) {
            throw new Error('No Sequelize instance passed');
          }
      
      
      Severity: Minor
      Found in src/model.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

      Function constructor has a Cognitive Complexity of 41 (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(
      Severity: Minor
      Found in src/associations/belongs-to-many.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

      Function upsertQuery has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

        upsertQuery(tableName, insertValues, updateValues, where, model) {
          const targetTableAlias = this.quoteTable(`${tableName}_target`);
          const sourceTableAlias = this.quoteTable(`${tableName}_source`);
          const primaryKeysAttrs = [];
          const identityAttrs = [];
      Severity: Minor
      Found in src/dialects/mssql/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

      Function update has 152 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static async update(values, options) {
          options = Utils.cloneDeep(options);
      
          this._injectScope(options);
          this._optionsMustContainWhere(options);
      Severity: Major
      Found in src/model.js - About 6 hrs to fix

        Function constructor has 150 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 src/sequelize.js - About 6 hrs to fix

          Function refreshAttributes has 150 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static refreshAttributes() {
              const attributeManipulation = {};
          
              this.prototype._customGetters = {};
              this.prototype._customSetters = {};
          Severity: Major
          Found in src/model.js - About 6 hrs to fix

            Function get has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
            Open

              get(key, options) {
                if (options === undefined && typeof key === 'object') {
                  options = key;
                  key = undefined;
                }
            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

            File utils.js has 411 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const DataTypes = require('./data-types');
            const SqlString = require('./sql-string');
            const _ = require('lodash');
            const baseIsNative = require('lodash/_baseIsNative');
            const uuidv1 = require('uuid').v1;
            Severity: Minor
            Found in src/utils.js - About 5 hrs to fix

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

              const Utils = require('../../utils');
              const Transaction = require('../../transaction');
              const _ = require('lodash');
              const MySqlQueryGenerator = require('../mysql/query-generator');
              const AbstractQueryGenerator = require('../abstract/query-generator');
              Severity: Minor
              Found in src/dialects/sqlite/query-generator.js - About 5 hrs to fix

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

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

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

                    formatResults(data, rowCount) {
                      if (this.isInsertQuery(data)) {
                        this.handleInsertQuery(data);
                        return [this.instance || data, rowCount];
                      }
                  Severity: Minor
                  Found in src/dialects/mssql/query.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 generateJoin has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                  Open

                    generateJoin(include, topLevelInfo) {
                      const association = include.association;
                      const parent = include.parent;
                      const parentIsTop =
                        !!parent && !include.parent.association && include.parent.model.name === topLevelInfo.options.model.name;
                  Severity: Minor
                  Found in src/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 _validateIncludedElement has a Cognitive Complexity of 37 (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 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 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];
                        const fieldName = dataType.field || name;
                  Severity: Minor
                  Found in src/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

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

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

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

                      async query(sql, options) {
                        options = { ...this.options.query, ...options };
                    
                        if (options.instance && !options.model) {
                          options.model = options.instance.constructor;
                    Severity: Minor
                    Found in src/sequelize.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

                    Severity
                    Category
                    Status
                    Source
                    Language