sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

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

export function escape(val: unknown, timeZone: string | null, dialect: string, format = false): string {
  let prependN = false;
  if (val === undefined || val === null) {
    return 'NULL';
  }
Severity: Minor
Found in src/sql-string.ts - 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 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  formatError(err) {
    let match;
    let table;
    let index;
    let fields;
Severity: Major
Found in src/dialects/postgres/query.js - About 3 hrs to fix

    Function generateJoin has 88 lines of code (exceeds 25 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: Major
    Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

      Function initPools has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initPools() {
          const config = this.config;
      
          if (!config.replication) {
            this.pool = new Pool({
      Severity: Major
      Found in src/dialects/abstract/connection-manager.js - About 3 hrs to fix

        Function handleInsertQuery has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          handleInsertQuery(results, metaData) {
            if (this.instance) {
              // add the inserted row id to the instance
              const autoIncrementAttribute = this.model.autoIncrementAttribute;
              let id = null;
        Severity: Minor
        Found in src/dialects/mssql/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 updateQuery has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          updateQuery(tableName, attrValueHash, where, options, attributes) {
            options = options || {};
            _.defaults(options, this.options);
        
            attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, options.omitNull, options);
        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 getConnection has a Cognitive Complexity of 24 (exceeds 5 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 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 scope has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          static scope(option) {
            const self = class extends this {};
            let scope;
            let scopeName;
        
        
        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

        Function set has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async set(sourceInstance, newAssociatedObjects, options) {
            options = options || {};
        
            const sourceKey = this.sourceKey;
            const targetKey = this.targetKey;
        Severity: Major
        Found in src/associations/belongs-to-many.js - About 3 hrs to fix

          Function upsertQuery has 84 lines of code (exceeds 25 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: Major
          Found in src/dialects/mssql/query-generator.js - About 3 hrs to fix

            Function findOrCreate has 84 lines of code (exceeds 25 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: Major
            Found in src/model.js - About 3 hrs to fix

              Function addIndexQuery has 82 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                addIndexQuery(tableName, attributes, options, rawTablename) {
                  options = options || {};
              
                  if (!Array.isArray(attributes)) {
                    options = attributes;
              Severity: Major
              Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

                Function handleSequelizeMethod has 82 lines of code (exceeds 25 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: Major
                Found in src/dialects/abstract/query-generator.js - About 3 hrs to fix

                  Function exports has a Cognitive Complexity of 23 (exceeds 5 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: Minor
                  Found in src/dialects/mysql/data-types.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 set has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async set(sourceInstance, newAssociatedObjects, options) {
                      options = options || {};
                  
                      const sourceKey = this.sourceKey;
                      const targetKey = this.targetKey;
                  Severity: Minor
                  Found in src/associations/belongs-to-many.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 _injectAttributes has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _injectAttributes() {
                      this.identifier = this.foreignKey;
                      this.foreignIdentifier = this.otherKey;
                  
                      // remove any PKs previously defined by sequelize
                  Severity: Minor
                  Found in src/associations/belongs-to-many.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 sync has 81 lines of code (exceeds 25 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: Major
                  Found in src/model.js - About 3 hrs to fix

                    Function _expandIncludeAllElement has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      static _expandIncludeAllElement(includes, include) {
                        // check 'all' attribute provided is valid
                        let all = include.all;
                        delete include.all;
                    
                    
                    Severity: Major
                    Found in src/model.js - About 3 hrs to fix

                      Function add has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async add(sourceInstance, newInstances, options) {
                          // If newInstances is null or undefined, no-op
                          if (!newInstances) return Promise.resolve();
                      
                          options = { ...options };
                      Severity: Major
                      Found in src/associations/belongs-to-many.js - About 3 hrs to fix

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

                          attributeToSQL(attribute) {
                            if (!_.isPlainObject(attribute)) {
                              attribute = {
                                type: attribute
                              };
                        Severity: Minor
                        Found in src/dialects/mssql/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

                        Severity
                        Category
                        Status
                        Source
                        Language