sequelize/sequelize

View on GitHub

Showing 503 of 787 total issues

Function addAllIncludes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    (function addAllIncludes(parent, includes) {
      _.forEach(parent.associations, association => {
        if (all !== true && !all.includes(association.associationType)) {
          return;
        }
Severity: Minor
Found in src/model.js - About 1 hr to fix

    Function findOne has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function transform has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function transform($, filePath) {
        // The three <span>s are used to draw the menu button icon
        $('nav.navigation').prepend($('<button id="navigationHamburger" class="hamburger" type="button"><span class="line"></span><span class="line"></span><span class="line"></span></button>'));
        const menuGroupsScripts = fs.readFileSync(path.join(__dirname, '..', 'scripts', 'menu-groups.js'), 'utf8');
        $('body').append($(`<script>${menuGroupsScripts}</script>`));
      Severity: Minor
      Found in docs/transforms/menu-groups.js - About 1 hr to fix

        Function handleShowIndexesQuery has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          handleShowIndexesQuery(data) {
            // Group by index name, and collect all fields
            data = data.reduce((acc, item) => {
              if (!(item.index_name in acc)) {
                acc[item.index_name] = item;
        Severity: Minor
        Found in src/dialects/mssql/query.js - About 1 hr to fix

          Function _invokeCustomValidator has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async _invokeCustomValidator(validator, validatorType, optAttrDefined, optValue, optField) {
              let isAsync = false;
          
              const validatorArity = validator.length;
              // check if validator is async and requires a callback
          Severity: Minor
          Found in src/instance-validator.js - About 1 hr to fix

            Function removeConstraint has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async removeConstraint(tableName, constraintName, options) {
                const sql = this.queryGenerator.showConstraintsQuery(
                  tableName.tableName
                    ? tableName
                    : {
            Severity: Minor
            Found in src/dialects/mysql/query-interface.js - About 1 hr to fix

              Function jsonPathExtractionQuery has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                jsonPathExtractionQuery(column, path) {
                  let paths = _.toPath(path);
                  let pathStr;
                  const quotedColumn = this.isIdentifierQuoted(column) ? column : this.quoteIdentifier(column);
              
              
              Severity: Minor
              Found in src/dialects/abstract/query-generator.js - About 1 hr to fix

                Function _logQuery has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _logQuery(sql, debugContext, parameters) {
                    const { connection, options } = this;
                    const benchmark = this.sequelize.options.benchmark || options.benchmark;
                    const logQueryParameters = this.sequelize.options.logQueryParameters || options.logQueryParameters;
                    const startTime = Date.now();
                Severity: Minor
                Found in src/dialects/abstract/query.js - About 1 hr to fix

                  Function _injectAttributes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _injectAttributes() {
                      const newAttributes = {
                        [this.foreignKey]: {
                          type: this.options.keyType || this.source.rawAttributes[this.sourceKeyAttribute].type,
                          allowNull: true,
                  Severity: Minor
                  Found in src/associations/has-many.js - About 1 hr to fix

                    Function formatBindParameters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      static formatBindParameters(sql, values, dialect) {
                        const stringReplaceFunc = value => (typeof value === 'string' ? value.replace(/\0/g, '\\0') : value);
                    
                        let bindParam;
                        if (Array.isArray(values)) {
                    Severity: Minor
                    Found in src/dialects/postgres/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 _refreshTypeParser has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _refreshTypeParser(dataType) {
                        const arrayParserBuilder = parser => {
                          return value => this.lib.types.arrayParser.create(value, parser).parse();
                        };
                        const rangeParserBuilder = parser => {
                    Severity: Minor
                    Found in src/dialects/postgres/connection-manager.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      attributesToSQL(attributes, options) {
                        const result = {},
                          existingConstraints = [];
                        let key, attribute;
                    
                    
                    Severity: Minor
                    Found in src/dialects/mssql/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 format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      format(value, field, options, bindParam) {
                        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

                    Function describeTable has a Cognitive Complexity of 10 (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/abstract/query-interface.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 initPools has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      initPools() {
                        const config = this.config;
                    
                        if (!config.replication) {
                          this.pool = new Pool({
                    Severity: Minor
                    Found in src/dialects/abstract/connection-manager.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 destroy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async destroy(options) {
                        options = {
                          hooks: true,
                          force: false,
                          ...options
                    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 upsert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async upsert(tableName, insertValues, updateValues, where, options) {
                        const model = options.model;
                        const wheres = [];
                    
                        options = { ...options };
                    Severity: Minor
                    Found in src/dialects/mssql/query-interface.js - About 1 hr to fix

                      Function run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async run(sql, parameters) {
                          this.sql = sql;
                          const { connection, options } = this;
                      
                          const showWarnings = this.sequelize.options.showWarnings || options.showWarnings;
                      Severity: Minor
                      Found in src/dialects/mariadb/query.js - About 1 hr to fix

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

                          Function removeColumn has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async removeColumn(tableName, columnName, options) {
                              options = options || {};
                          
                              const [results] = await this.sequelize.query(
                                this.queryGenerator.getForeignKeyQuery(
                          Severity: Minor
                          Found in src/dialects/mysql/query-interface.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language