sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function getConstraintSnippet has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getConstraintSnippet(tableName, options) {
    let constraintSnippet, constraintName;

    const fieldsSql = options.fields.map(field => {
      if (typeof field === 'string') {
Severity: Major
Found in src/dialects/abstract/query-generator.js - About 2 hrs to fix

    Function findAll has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async findAll(options) {
        if (options !== undefined && !_.isPlainObject(options)) {
          throw new sequelizeErrors.QueryError(
            'The argument passed to findAll must be an options object, use findByPk if you wish to pass a single primary key value'
          );
    Severity: Major
    Found in src/model.js - About 2 hrs to fix

      Function destroy has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static async destroy(options) {
          options = Utils.cloneDeep(options);
      
          this._injectScope(options);
      
      
      Severity: Major
      Found in src/model.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                  subQuery &&
                  Array.isArray(order) &&
                  order[0] &&
                  !(order[0] instanceof Association) &&
        Severity: Critical
        Found in src/dialects/abstract/query-generator.js - About 2 hrs to fix

          Function attributeToSQL has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            attributeToSQL(attribute) {
              if (!_.isPlainObject(attribute)) {
                attribute = {
                  type: attribute
                };
          Severity: Major
          Found in src/dialects/mssql/query-generator.js - About 2 hrs to fix

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

              createTableQuery(tableName, attributes, options) {
                options = {
                  engine: 'InnoDB',
                  charset: null,
                  rowFormat: null,
            Severity: Major
            Found in src/dialects/mysql/query-generator.js - About 2 hrs to fix

              Function escape has 65 lines of code (exceeds 25 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: Major
              Found in src/sql-string.ts - About 2 hrs to fix

                Function _refreshDynamicOIDs has a Cognitive Complexity of 19 (exceeds 5 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 2 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 attributeToSQL has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  attributeToSQL(attribute, options) {
                    if (!_.isPlainObject(attribute)) {
                      attribute = {
                        type: attribute
                      };
                Severity: Minor
                Found in src/dialects/mysql/query-generator.js - About 2 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 increment has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static async increment(fields, options) {
                    options = options || {};
                    if (typeof fields === 'string') fields = [fields];
                    if (Array.isArray(fields)) {
                      fields = fields.map(f => {
                Severity: Major
                Found in src/model.js - About 2 hrs to fix

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

                    constructor(source, target, options) {
                      super(source, target, options);
                  
                      this.associationType = 'HasMany';
                      this.targetAssociation = null;
                  Severity: Major
                  Found in src/associations/has-many.js - About 2 hrs to fix

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

                      createTableQuery(tableName, attributes, options) {
                        const primaryKeys = [],
                          foreignKeys = {},
                          attributesClauseParts = [];
                    
                    
                    Severity: Major
                    Found in src/dialects/mssql/query-generator.js - About 2 hrs to fix

                      Function bulkInsertQuery has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        bulkInsertQuery(tableName, fieldValueHashes, options, fieldMappedAttributes) {
                          options = options || {};
                          fieldMappedAttributes = fieldMappedAttributes || {};
                      
                          const tuples = [];
                      Severity: Major
                      Found in src/dialects/abstract/query-generator.js - About 2 hrs to fix

                        Function handleSelectQuery has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          handleSelectQuery(results) {
                            let result = null;
                        
                            // Map raw fields to names if a mapping is provided
                            if (this.options.fieldMap) {
                        Severity: Major
                        Found in src/dialects/abstract/query.js - About 2 hrs to fix

                          Function formatError has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                            formatError(err) {
                              let match;
                          
                              match = err.message.match(
                                /Violation of (?:UNIQUE|PRIMARY) KEY constraint '([^']*)'. Cannot insert duplicate key in object '.*'.(:? The duplicate key value is \((.*)\).)?/
                          Severity: Minor
                          Found in src/dialects/mssql/query.js - About 2 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 _setInclude has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                          Open

                            _setInclude(key, value, options) {
                              if (!Array.isArray(value)) value = [value];
                              if (value[0] instanceof Model) {
                                value = value.map(instance => instance.dataValues);
                              }
                          Severity: Minor
                          Found in src/model.js - About 2 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 describeTable has a Cognitive Complexity of 18 (exceeds 5 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 2 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 _run has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async _run(connection, sql, parameters) {
                              this.sql = sql;
                              const { options } = this;
                          
                              const complete = this._logQuery(sql, debug, parameters);
                          Severity: Major
                          Found in src/dialects/mssql/query.js - About 2 hrs to fix

                            Function connect has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              async connect(config) {
                                const connectionConfig = {
                                  host: config.host,
                                  port: config.port,
                                  user: config.username,
                            Severity: Major
                            Found in src/dialects/mysql/connection-manager.js - About 2 hrs to fix

                              Function _addDefaultAttributes has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                static _addDefaultAttributes() {
                                  const tail = {};
                                  let head = {};
                              
                                  // Add id if no primary key was manually added to definition
                              Severity: Major
                              Found in src/model.js - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language