Showing 40 of 74 total issues
Function getTypeScriptFieldType
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private getTypeScriptFieldType(fieldObj: TSField, attr: keyof TSField) {
const rawFieldType = fieldObj[attr] || '';
const fieldType = String(rawFieldType).toLowerCase();
let jsType: 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 constructor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(database: string | Sequelize, username: string, password: string, options: AutoOptions) {
if (options && options.dialect === 'sqlite' && !options.storage && database) {
options.storage = database as string;
}
if (options && options.dialect === 'mssql') {
Function recase
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function recase(opt: CaseOption | CaseFileOption | undefined, val: string | null, singular = false) {
if (singular && val) {
val = singularize(val);
}
if (!opt || opt === 'o' || !val) {
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
constructor(database: string | Sequelize, username: string, password: string, options: AutoOptions) {
if (options && options.dialect === 'sqlite' && !options.storage && database) {
options.storage = database as string;
}
if (options && options.dialect === 'mssql') {
- 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 deeply nested control flow statements. Open
if (this.dialect.name === "mssql" && defaultVal && defaultVal.toLowerCase() === '(newid())') {
defaultVal = null as any; // disable adding "default value" attribute for UUID fields if generating for MS SQL
}
Avoid deeply nested control flow statements. Open
if (isSerialKey) {
return true; // value generated in the database
}
Avoid deeply nested control flow statements. Open
} else if (attr === "comment" && (!fieldObj[attr] || this.dialect.name === "mssql")) {
return true;
} else {
let val = (attr !== "type") ? null : this.getSqType(fieldObj, attr);
if (val == null) {
Avoid deeply nested control flow statements. Open
if (this.dialect.name === "postgres" && fieldObj.foreignKey && fieldObj.foreignKey.isPrimaryKey === true && (fieldObj.foreignKey.generation === "ALWAYS" || fieldObj.foreignKey.generation === "BY DEFAULT")) {
str += space[3] + "autoIncrementIdentity: true,\n";
}
Avoid deeply nested control flow statements. Open
if (_.isString(defaultVal)) {
const field_type = fieldObj.type.toLowerCase();
defaultVal = this.escapeSpecial(defaultVal);
while (defaultVal.startsWith('(') && defaultVal.endsWith(')')) {
Avoid deeply nested control flow statements. Open
if (this.dialect.name === "mssql" && (["(NULL)", "NULL"].includes(defaultVal) || typeof defaultVal === "undefined")) {
defaultVal = null as any; // Override default NULL in MS SQL to javascript null
}
Avoid deeply nested control flow statements. Open
if (defaultVal === null || defaultVal === undefined) {
return true;
}
Function getAlias
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private getAlias(fkFieldName: string, modelName: string, targetModel: string, isM2M = false) {
let name = this.trimId(fkFieldName);
if (name === fkFieldName || isM2M) {
name = fkFieldName + "_" + modelName;
}
- 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 addSchemaForRelations
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private addSchemaForRelations(table: string) {
if (!table.includes('.') && !this.relations.some(rel => rel.childTable === table)) {
// if no tables match the given table, then assume we need to fix the schema
const first = this.relations.find(rel => !!rel.childTable);
if (first) {
- 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 val;
Avoid too many return
statements within this function. Open
return _.snakeCase(val).toUpperCase();
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return _.upperFirst(_.camelCase(val));
Avoid too many return
statements within this function. Open
return true; // value generated in the database
Avoid too many return
statements within this function. Open
return true;