Showing 40 of 74 total issues
File auto-generator.ts
has 680 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from "lodash";
import { ColumnDescription } from "sequelize/types";
import { DialectOptions, FKSpec } from "./dialects/dialect-options";
import { AutoOptions, CaseFileOption, CaseOption, Field, IndexSpec, LangOption, makeIndent, makeTableName, pluralize, qNameJoin, qNameSplit, recase, Relation, singularize, TableData, TSField } from "./types";
Function getSqType
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
private getSqType(fieldObj: Field, attr: string): string {
const attrValue = (fieldObj as any)[attr];
if (!attrValue.toLowerCase) {
console.log("attrValue", attr, attrValue);
return attrValue;
- 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 addField
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addField(table: string, field: string): string {
// ignore Sequelize standard fields
const additional = this.options.additional;
if (additional && (additional.timestamps !== false) && (this.isTimestampField(field) || this.isParanoidField(field))) {
Function getSqType
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
private getSqType(fieldObj: Field, attr: string): string {
const attrValue = (fieldObj as any)[attr];
if (!attrValue.toLowerCase) {
console.log("attrValue", attr, attrValue);
return attrValue;
AutoGenerator
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
export class AutoGenerator {
dialect: DialectOptions;
tables: { [tableName: string]: { [fieldName: string]: ColumnDescription; }; };
foreignKeys: { [tableName: string]: { [fieldName: string]: FKSpec; }; };
hasTriggerTables: { [tableName: string]: boolean; };
Function addTypeScriptAssociationMixins
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addTypeScriptAssociationMixins(table: string): Record<string, any> {
const sp = this.space[1];
const needed: Record<string, Set<String>> = {};
let str = '';
Function mapTable
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async mapTable(table: Table) {
try {
const fields = await this.queryInterface.describeTable(table.table_name, table.table_schema);
this.tableData.tables[makeTableQName(table)] = fields;
Function generateText
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateText() {
const tableNames = _.keys(this.tables);
const header = this.makeHeaderTemplate();
Function mapTable
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private async mapTable(table: Table) {
try {
const fields = await this.queryInterface.describeTable(table.table_name, table.table_schema);
this.tableData.tables[makeTableQName(table)] = fields;
- 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 addTable
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addTable(table: string) {
const [schemaName, tableNameOrig] = qNameSplit(table);
const space = this.space;
let timestamps = (this.options.additional && this.options.additional.timestamps === true) || false;
Function mapForeignKeys
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private mapForeignKeys(table: Table) {
const tableQname = makeTableQName(table);
const sql = this.dialect.getForeignKeysQuery(table.table_name, table.table_schema || this.sequelize.getDatabaseName());
const dialect = this.dialect;
- 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 addField
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private addField(table: string, field: string): string {
// ignore Sequelize standard fields
const additional = this.options.additional;
if (additional && (additional.timestamps !== false) && (this.isTimestampField(field) || this.isParanoidField(field))) {
- 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 addRelation
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addRelation(table: string, fkFieldName: string, spec: FKSpec, fkFields: { [fieldName: string]: FKSpec; }) {
const [schemaName, tableName] = qNameSplit(table);
const schema = schemaName as string;
const modelName = recase(this.caseModel, tableName, this.singularize);
Function addIndexes
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addIndexes(table: string) {
const indexes = this.indexes[table];
const space = this.space;
let str = "";
if (indexes && indexes.length) {
Function makeHeaderTemplate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
makeHeaderTemplate() {
let header = "";
const sp = this.space[1];
if (this.options.lang === 'ts') {
Function createTsInitString
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private createTsInitString(tables: string[], assoc: string) {
let str = 'import type { Sequelize } from "sequelize";\n';
const sp = this.space[1];
const modelNames: string[] = [];
// import statements
Function addTable
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private addTable(table: string) {
const [schemaName, tableNameOrig] = qNameSplit(table);
const space = this.space;
let timestamps = (this.options.additional && this.options.additional.timestamps === true) || 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 mapForeignKeys
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private mapForeignKeys(table: Table) {
const tableQname = makeTableQName(table);
const sql = this.dialect.getForeignKeysQuery(table.table_name, table.table_schema || this.sequelize.getDatabaseName());
const dialect = this.dialect;
Function makeHeaderTemplate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
makeHeaderTemplate() {
let header = "";
const sp = this.space[1];
if (this.options.lang === 'ts') {
- 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 addRelation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private addRelation(table: string, fkFieldName: string, spec: FKSpec, fkFields: { [fieldName: string]: FKSpec; }) {
const [schemaName, tableName] = qNameSplit(table);
const schema = schemaName as string;
const modelName = recase(this.caseModel, tableName, this.singularize);
- 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"