File utils.js
has 411 lines of code (exceeds 250 allowed). Consider refactoring. Open
const DataTypes = require('./data-types');
const SqlString = require('./sql-string');
const _ = require('lodash');
const baseIsNative = require('lodash/_baseIsNative');
const uuidv1 = require('uuid').v1;
Function mapWhereFieldNames
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mapWhereFieldNames(attributes, Model) {
if (attributes) {
getComplexKeys(attributes).forEach(attribute => {
const rawAttribute = Model.rawAttributes[attribute];
Function toDefaultValue
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function toDefaultValue(value, dialect) {
if (typeof value === 'function') {
const tmp = value();
if (tmp instanceof DataTypes.ABSTRACT) {
return tmp.toSql();
- 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 mapOptionFieldNames
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function mapOptionFieldNames(options, Model) {
if (Array.isArray(options.attributes)) {
options.attributes = options.attributes.map(attr => {
// Object lookups will force any variable to strings, we don't want that for special objects etc
if (typeof attr !== 'string') return attr;
- 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 mapValueFieldNames
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function mapValueFieldNames(dataValues, fields, Model) {
const values = {};
for (const attr of fields) {
if (dataValues[attr] !== undefined && !Model._virtualAttributes.has(attr)) {
- 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
Avoid too many return
statements within this function. Open
return value.slice();
Avoid too many return
statements within this function. Open
return { ...value };
Avoid too many return
statements within this function. Open
return now(dialect);
Avoid too many return
statements within this function. Open
return value;
Function nameIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function nameIndex(index, tableName) {
if (tableName.tableName) tableName = tableName.tableName;
if (!Object.prototype.hasOwnProperty.call(index, 'name')) {
const fields = index.fields.map(field => (typeof field === 'string' ? field : field.name || field.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"