sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function formatError has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  formatError(err) {
    switch (err.code) {
      case 'SQLITE_CONSTRAINT': {
        if (err.message.includes('FOREIGN KEY constraint failed')) {
          return new sequelizeErrors.ForeignKeyConstraintError({
Severity: Major
Found in src/dialects/sqlite/query.js - About 2 hrs to fix

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

      async set(sourceInstance, targetInstances, options) {
        if (targetInstances === null) {
          targetInstances = [];
        } else {
          targetInstances = this.toInstanceArray(targetInstances);
    Severity: Major
    Found in src/associations/has-many.js - About 2 hrs to fix

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

        async get(instances, options = {}) {
          const where = {};
      
          let Model = this.target;
          let instance;
      Severity: Major
      Found in src/associations/has-many.js - About 2 hrs to fix

        Function updateAssociations has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const updateAssociations = currentRows => {
              const promises = [];
              const unassociatedObjects = [];
              const changedAssociations = [];
              for (const obj of newInstances) {
        Severity: Major
        Found in src/associations/belongs-to-many.js - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

              if (this.instance) {
                // add the inserted row id to the instance
                const autoIncrementAttribute = this.model.autoIncrementAttribute;
                let id = null;
                let autoIncrementAttributeAlias = null;
          Severity: Critical
          Found in src/dialects/mssql/query.js - About 2 hrs to fix

            Function updateQuery has 49 lines of code (exceeds 25 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/sqlite/query-generator.js - About 1 hr to fix

              Function describeTable has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async describeTable(tableName, options) {
                  let schema = null;
                  let schemaDelimiter = null;
              
                  if (typeof options === 'string') {
              Severity: Minor
              Found in src/dialects/sqlite/query-interface.js - About 1 hr to fix

                Function _checkValidJsonStatement has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  _checkValidJsonStatement(stmt) {
                    if (typeof stmt !== 'string') {
                      return false;
                    }
                
                
                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 runHooks has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  async runHooks(hooks, ...hookArgs) {
                    if (!hooks) throw new Error('runHooks requires at least 1 argument');
                
                    let hookType;
                
                
                Severity: Minor
                Found in src/hooks.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 quote has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  quote(collection, parent, connector) {
                    // init
                    const validOrderOptions = [
                      'ASC',
                      'DESC',
                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 constructor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  constructor(source, target, options) {
                    super(source, target, options);
                
                    this.associationType = 'HasMany';
                    this.targetAssociation = null;
                Severity: Minor
                Found in src/associations/has-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 get has a Cognitive Complexity of 15 (exceeds 5 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

                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 _checkValidJsonStatement has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Function restore has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    static async restore(options) {
                      if (!this._timestampAttributes.deletedAt) throw new Error('Model is not paranoid');
                  
                      options = {
                        hooks: true,
                  Severity: Minor
                  Found in src/model.js - About 1 hr to fix

                    Function createTableQuery has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      createTableQuery(tableName, attributes, options) {
                        options = { ...options };
                    
                        //Postgres 9.0 does not support CREATE TABLE IF NOT EXISTS, 9.1 and above do
                        const databaseVersion = _.get(this, 'sequelize.options.databaseVersion', 0);
                    Severity: Minor
                    Found in src/dialects/postgres/query-generator.js - About 1 hr to fix

                      Function _validateSchema has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _validateSchema(rawAttribute, field, value) {
                          if (rawAttribute.allowNull === false && (value === null || value === undefined)) {
                            const association = Object.values(this.modelInstance.constructor.associations).find(
                              association => association instanceof BelongsTo && association.foreignKey === rawAttribute.fieldName
                            );
                      Severity: Minor
                      Found in src/instance-validator.js - About 1 hr to fix

                        Function selectFromTableFragment has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          selectFromTableFragment(options, model, attributes, tables, mainTableAs, where) {
                            this._throwOnEmptyAttributes(attributes, {
                              modelName: model && model.name,
                              as: mainTableAs
                            });
                        Severity: Minor
                        Found in src/dialects/mssql/query-generator.js - About 1 hr to fix

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

                            Function createTableQuery has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              createTableQuery(tableName, attributes, options) {
                                options = options || {};
                            
                                const primaryKeys = [];
                                const needsMultiplePrimaryKeys =
                            Severity: Minor
                            Found in src/dialects/sqlite/query-generator.js - About 1 hr to fix

                              Function scope has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static scope(option) {
                                  const self = class extends this {};
                                  let scope;
                                  let scopeName;
                              
                              
                              Severity: Minor
                              Found in src/model.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language