Showing 503 of 787 total issues
Function _refreshTypeParser
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_refreshTypeParser(dataType) {
const arrayParserBuilder = parser => {
return value => this.lib.types.arrayParser.create(value, parser).parse();
};
const rangeParserBuilder = parser => {
Function handleSequelizeMethod
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleSequelizeMethod(smth, tableName, factory, options, prepend) {
if (smth instanceof Utils.Json) {
// Parse nested object
if (smth.conditions) {
const conditions = this.parseConditionObject(smth.conditions).map(
Consider simplifying this complex logical expression. Open
if (this.isInsertQuery() || this.isUpdateQuery() || this.isUpsertQuery()) {
if (this.instance && this.instance.dataValues) {
for (const key in rows[0]) {
if (Object.prototype.hasOwnProperty.call(rows[0], key)) {
const record = rows[0][key];
Consider simplifying this complex logical expression. Open
if (isSQLServer2008 && options.offset) {
// For earlier versions of SQL server, we need to nest several queries
// in order to emulate the OFFSET behavior.
//
// 1. The outermost query selects all items from the inner query block.
Function _singleAttrValidate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _singleAttrValidate(value, field, allowNull) {
// If value is null and allowNull is false, no validators should run (see #9143)
if ((value === null || value === undefined) && !allowNull) {
// The schema validator (_validateSchema) has already generated the validation error. Nothing to do here.
return;
Function sync
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async sync(options) {
options = {
...this.options,
...this.options.sync,
...options,
Function renameColumnQuery
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
renameColumnQuery(tableName, attrNameBefore, attrNameAfter, attributes) {
let backupTableName;
attributes = this.attributesToSQL(attributes);
Function destroy
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async destroy(options) {
options = {
hooks: true,
force: false,
...options
Function rawSelect
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async rawSelect(tableName, options, attributeSelector, Model) {
options = Utils.cloneDeep(options);
options = _.defaults(options, {
raw: true,
plain: true,
Function _findSeparate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async _findSeparate(results, options) {
if (!options.include || options.raw || !results) return results;
const original = results;
if (options.plain) results = [results];
Function arithmeticQuery
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
arithmeticQuery(operator, tableName, where, incrementAmountsByField, extraAttributesToBeUpdated, options) {
options = options || {};
_.defaults(options, { returning: true });
extraAttributesToBeUpdated = Utils.removeNullValuesFromHash(extraAttributesToBeUpdated, this.options.omitNull);
Function fieldsSql
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const fieldsSql = options.fields.map(field => {
if (field instanceof Utils.SequelizeMethod) {
return this.handleSequelizeMethod(field);
}
if (typeof field === 'string') {
Function _getIncludedAssociation
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _getIncludedAssociation(targetModel, targetAlias) {
const associations = this.getAssociations(targetModel);
let association = null;
if (associations.length === 0) {
throw new sequelizeErrors.EagerLoadingError(`${targetModel.name} is not associated to ${this.name}!`);
Function forEachModel
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public forEachModel(iterator: (m: typeof Model) => void, options: { reverse: boolean } = { reverse: true }): void {
const models: Record<string, typeof Model> = {};
const sorter = new Toposort();
for (const model of this.models) {
Function set
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async set(sourceInstance, associatedInstance, options) {
options = { ...options, scope: false };
const oldInstance = await sourceInstance[this.accessors.get](options);
// TODO Use equals method once #5605 is resolved
Function sync
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async sync(options) {
options = {
...this.options,
...this.options.sync,
...options,
- Read upRead up
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 getSQLTypeFromJsType
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getSQLTypeFromJsType(value, TYPES) {
const paramType = { type: TYPES.VarChar, typeOptions: {} };
paramType.type = TYPES.NVarChar;
if (typeof value === 'number') {
if (Number.isInteger(value)) {
- Read upRead up
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 connect
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async connect(config) {
// Named timezone is not supported in mariadb, convert to offset
let tzOffset = this.sequelize.options.timezone;
tzOffset = /\//.test(tzOffset) ? momentTz.tz(tzOffset).format('Z') : tzOffset;
- Read upRead up
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 createTableQuery
has a Cognitive Complexity of 11 (exceeds 5 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);
- Read upRead up
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 _validateSchema
has a Cognitive Complexity of 11 (exceeds 5 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
);
- Read upRead up
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"