File dumper.js
has 395 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const { plural, singular } = require('pluralize');
const stringUtils = require('../utils/strings');
const toValidPackageName = require('../utils/to-valid-package-name');
const IncompatibleLianaForUpdateError = require('../utils/errors/dumper/incompatible-liana-for-update-error');
Dumper
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Dumper {
constructor({
fs,
chalk,
constants,
Function dump
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async dump(schema, config) {
const cwd = process.cwd();
const projectPath = config.appName ? `${cwd}/${config.appName}` : cwd;
const { isUpdate, useMultiDatabase, modelsExportPath } = config;
Function writeModel
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
writeModel(projectPath, config, table, fields, references, options = {}) {
const { underscored } = options;
let modelPath = `models/${Dumper.tableToFilename(table)}.js`;
if (config.useMultiDatabase) {
modelPath = `models/${config.modelsExportPath}/${Dumper.tableToFilename(table)}.js`;
Function writePackageJson
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
writePackageJson(projectPath, { dbDialect, appName }) {
const orm = dbDialect === 'mongodb' ? 'mongoose' : 'sequelize';
const dependencies = {
'body-parser': '1.19.0',
chalk: '~1.1.3',
Function writeModel
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
writeModel(projectPath, config, table, fields, references, options = {}) {
const { underscored } = options;
let modelPath = `models/${Dumper.tableToFilename(table)}.js`;
if (config.useMultiDatabase) {
modelPath = `models/${config.modelsExportPath}/${Dumper.tableToFilename(table)}.js`;
- 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 getDatabaseUrl
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static getDatabaseUrl(config) {
let connectionString;
if (config.dbConnectionUrl) {
connectionString = config.dbConnectionUrl;
- 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 dump
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async dump(schema, config) {
const cwd = process.cwd();
const projectPath = config.appName ? `${cwd}/${config.appName}` : cwd;
const { isUpdate, useMultiDatabase, modelsExportPath } = config;
- 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 writePackageJson
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
writePackageJson(projectPath, { dbDialect, appName }) {
const orm = dbDialect === 'mongodb' ? 'mongoose' : 'sequelize';
const dependencies = {
'body-parser': '1.19.0',
chalk: '~1.1.3',
- 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"