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') {
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'
);
Function destroy
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async destroy(options) {
options = Utils.cloneDeep(options);
this._injectScope(options);
Consider simplifying this complex logical expression. Open
if (
subQuery &&
Array.isArray(order) &&
order[0] &&
!(order[0] instanceof Association) &&
Function attributeToSQL
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
attributeToSQL(attribute) {
if (!_.isPlainObject(attribute)) {
attribute = {
type: attribute
};
Function createTableQuery
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
createTableQuery(tableName, attributes, options) {
options = {
engine: 'InnoDB',
charset: null,
rowFormat: null,
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';
}
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
- 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 attributeToSQL
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
attributeToSQL(attribute, options) {
if (!_.isPlainObject(attribute)) {
attribute = {
type: attribute
};
- 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 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 => {
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;
Function createTableQuery
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
createTableQuery(tableName, attributes, options) {
const primaryKeys = [],
foreignKeys = {},
attributesClauseParts = [];
Function bulkInsertQuery
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
bulkInsertQuery(tableName, fieldValueHashes, options, fieldMappedAttributes) {
options = options || {};
fieldMappedAttributes = fieldMappedAttributes || {};
const tuples = [];
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) {
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 \((.*)\).)?/
- 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 _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);
}
- 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 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') {
- 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 _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);
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,
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