sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function changeColumnQuery has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  changeColumnQuery(tableName, attributes) {
    const query = subQuery => `ALTER TABLE ${this.quoteTable(tableName)} ALTER COLUMN ${subQuery};`;
    const sql = [];
    for (const attributeName in attributes) {
      let definition = this.dataTypeMapping(tableName, attributeName, attributes[attributeName]);
Severity: Minor
Found in src/dialects/postgres/query-generator.js - About 1 hr 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 quoteTable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  quoteTable(param, alias) {
    let table = '';

    if (alias === true) {
      alias = param.as || param.name || param;
Severity: Minor
Found in src/dialects/abstract/query-generator.js - About 1 hr 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 aggregate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  static async aggregate(attribute, aggregateFunction, options) {
    options = Utils.cloneDeep(options);

    // We need to preserve attributes here as the `injectScope` call would inject non aggregate columns.
    const prevAttributes = options.attributes;
Severity: Minor
Found in src/model.js - About 1 hr 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 get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  async get(instance, options) {
    options = Utils.cloneDeep(options) || {};

    const through = this.through;
    let scopeWhere;
Severity: Minor
Found in src/associations/belongs-to-many.js - About 1 hr 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 43 lines of code (exceeds 25 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 1 hr to fix

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

      constructor(source, target, options) {
        super(source, target, options);
    
        this.associationType = 'HasOne';
        this.isSingleAssociation = true;
    Severity: Minor
    Found in src/associations/has-one.js - About 1 hr to fix

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

        constructor(source, target, options) {
          super(source, target, options);
      
          this.associationType = 'BelongsTo';
          this.isSingleAssociation = true;
      Severity: Minor
      Found in src/associations/belongs-to.js - About 1 hr to fix

        Function _checkValidJsonStatement has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _checkValidJsonStatement(stmt) {
            if (typeof stmt !== 'string') {
              return false;
            }
        
        
        Severity: Minor
        Found in src/dialects/mysql/query-generator.js - About 1 hr to fix

          Function aggregate has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static async aggregate(attribute, aggregateFunction, options) {
              options = Utils.cloneDeep(options);
          
              // We need to preserve attributes here as the `injectScope` call would inject non aggregate columns.
              const prevAttributes = options.attributes;
          Severity: Minor
          Found in src/model.js - About 1 hr to fix

            Function get has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async get(instance, options) {
                options = Utils.cloneDeep(options) || {};
            
                const through = this.through;
                let scopeWhere;
            Severity: Minor
            Found in src/associations/belongs-to-many.js - About 1 hr to fix

              Function get has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async get(instances, options) {
                  const where = {};
                  let Target = this.target;
                  let instance;
              
              
              Severity: Minor
              Found in src/associations/belongs-to.js - About 1 hr to fix

                Function escapeAttributes has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  escapeAttributes(attributes, options, mainTableAs) {
                    return (
                      attributes &&
                      attributes.map(attr => {
                        let addTable = true;
                Severity: Minor
                Found in src/dialects/abstract/query-generator.js - About 1 hr to fix

                  Function get has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async get(instances, options) {
                      const where = {};
                  
                      let Target = this.target;
                      let instance;
                  Severity: Minor
                  Found in src/associations/has-one.js - About 1 hr to fix

                    Function _refreshDynamicOIDs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async _refreshDynamicOIDs(connection) {
                        const databaseVersion = this.sequelize.options.databaseVersion;
                        const supportedVersion = '8.3.0';
                    
                        // Check for supported version
                    Severity: Minor
                    Found in src/dialects/postgres/connection-manager.js - About 1 hr to fix

                      Function changeColumnQuery has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        changeColumnQuery(tableName, attributes) {
                          const query = subQuery => `ALTER TABLE ${this.quoteTable(tableName)} ALTER COLUMN ${subQuery};`;
                          const sql = [];
                          for (const attributeName in attributes) {
                            let definition = this.dataTypeMapping(tableName, attributeName, attributes[attributeName]);
                      Severity: Minor
                      Found in src/dialects/postgres/query-generator.js - About 1 hr to fix

                        Function addLimitAndOffset has 40 lines of code (exceeds 25 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 1 hr to fix

                          Function getConnection has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async getConnection(options) {
                              options = options || {};
                          
                              if (this.sequelize.options.databaseVersion === 0) {
                                if (!this.versionPromise) {
                          Severity: Minor
                          Found in src/dialects/abstract/connection-manager.js - About 1 hr to fix

                            Function normalizeAttribute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                              normalizeAttribute(attribute) {
                                if (!_.isPlainObject(attribute)) {
                                  attribute = { type: attribute };
                                }
                            
                            
                            Severity: Minor
                            Found in src/sequelize.js - About 1 hr 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 logWarnings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                              async logWarnings(results) {
                                const warningResults = await this.run('SHOW WARNINGS');
                                const warningMessage = `MariaDB Warnings (${this.connection.uuid || 'default'}): `;
                                const messages = [];
                                for (const _warningRow of warningResults) {
                            Severity: Minor
                            Found in src/dialects/mariadb/query.js - About 1 hr 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 escape has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                              escape(value, field, options) {
                                options = options || {};
                            
                                if (value !== null && value !== undefined) {
                                  if (value instanceof Utils.SequelizeMethod) {
                            Severity: Minor
                            Found in src/dialects/abstract/query-generator.js - About 1 hr 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