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({
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);
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;
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) {
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;
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);
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') {
Function _checkValidJsonStatement
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_checkValidJsonStatement(stmt) {
if (typeof stmt !== 'string') {
return false;
}
- 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 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;
- 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 quote
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
quote(collection, parent, connector) {
// init
const validOrderOptions = [
'ASC',
'DESC',
- 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 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;
- 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 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;
- 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 _checkValidJsonStatement
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
_checkValidJsonStatement(stmt) {
if (typeof stmt !== 'string') {
return false;
}
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,
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);
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
);
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
});
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;
}
Function createTableQuery
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
createTableQuery(tableName, attributes, options) {
options = options || {};
const primaryKeys = [];
const needsMultiplePrimaryKeys =
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;