sequelize/sequelize

View on GitHub

Showing 454 of 746 total issues

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

Function constructor has 133 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 _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 _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 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 generateInclude has 131 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 attributeToSQL has a Cognitive Complexity of 34 (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 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 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 _handleQueryResponse has 127 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 lib/dialects/sqlite/query.js - About 5 hrs to fix

        File query-generator.js has 376 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 5 hrs to fix

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

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

            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

              Function bulkCreate has 123 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

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

                    formatResults(data) {
                      let result = this.instance;
                  
                      if (this.isBulkUpdateQuery() || this.isBulkDeleteQuery()
                        || this.isUpsertQuery()) {
                  Severity: Minor
                  Found in lib/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 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

                  Function insertQuery has 118 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 lib/dialects/abstract/query-generator.js - About 4 hrs to fix

                    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 lib/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 exports has 114 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 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language