ForestAdmin/lumber

View on GitHub
services/dumper.js

Summary

Maintainability
D
2 days
Test Coverage
A
99%

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');
Severity: Minor
Found in services/dumper.js - About 5 hrs to fix

    Dumper has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Dumper {
      constructor({
        fs,
        chalk,
        constants,
    Severity: Minor
    Found in services/dumper.js - About 3 hrs to fix

      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;
      
      
      Severity: Minor
      Found in services/dumper.js - About 1 hr to fix

        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`;
        Severity: Minor
        Found in services/dumper.js - About 1 hr to fix

          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',
          Severity: Minor
          Found in services/dumper.js - About 1 hr to fix

            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`;
            Severity: Minor
            Found in services/dumper.js - About 1 hr to fix

            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;
            Severity: Minor
            Found in services/dumper.js - About 35 mins to fix

            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;
            
            
            Severity: Minor
            Found in services/dumper.js - About 35 mins to fix

            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',
            Severity: Minor
            Found in services/dumper.js - About 35 mins to fix

            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

            There are no issues that match your filters.

            Category
            Status