ForestAdmin/toolbelt

View on GitHub

Showing 91 of 172 total issues

Function notifyError has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async notifyError(code = 'unknown_error', message = null, context = undefined) {
    if (!this.applicationName || !this.command) {
      return;
    }

Severity: Minor
Found in src/utils/event-sender.js - About 1 hr to fix

    Function deserialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function deserialize(error) {
      if (!error || !error.status) {
        throw new Error('Wrong API Error format');
      }
    
    
    Severity: Minor
    Found in src/deserializers/api-error.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 analyzeMongoCollections has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      async analyzeMongoCollections(databaseConnection) {
        const collections = await databaseConnection.collections();
        if (collections.length === 0) {
          this.restoreDefaultState();
          throw new EmptyDatabaseError('no collections found', {
    Severity: Minor
    Found in src/services/schema/update/analyzer/mongo-collections-analyzer.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 writePackageJson has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      writePackageJson(dbDialect, appName) {
        const orm = dbDialect === 'mongodb' ? 'mongoose' : 'sequelize';
        const dependencies = {
          'body-parser': '1.19.0',
          chalk: '~1.1.3',
    Severity: Minor
    Found in src/services/dumpers/forest-express.js - About 1 hr to fix

      Function connectToMongodb has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        connectToMongodb(options, isSSL) {
          let connectionOptionsMongoClient = options.connectionOptions;
          if (!connectionOptionsMongoClient) {
            connectionOptionsMongoClient = {
              useNewUrlParser: true,
      Severity: Minor
      Found in src/services/schema/update/database.js - About 1 hr to fix

        Function perform has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.perform = () => {
            try {
              apimap = reorderKeysBasic(apimap);
              apimap.data = sortArrayOfObjects(apimap.data);
        
        
        Severity: Minor
        Found in src/services/apimap-sorter.js - About 1 hr to fix

          Function withCurrentProject has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = async function withCurrentProject(config) {
            const { assertPresent, inquirer, spinner } = Context.inject();
            assertPresent({ inquirer, spinner });
          
            if (config.projectId) {
          Severity: Minor
          Found in src/services/with-current-project.js - About 1 hr to fix

            Function JobStateChecker has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function JobStateChecker(message, oclifExit) {
              const { assertPresent, authenticator, env, logger } = Context.inject();
              assertPresent({ authenticator, env, logger });
            
              const bar = new ProgressBar(`${message} [:bar] :percent `, { total: 100 });
            Severity: Minor
            Found in src/services/job-state-checker.js - About 1 hr to fix

              Function withCurrentProject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = async function withCurrentProject(config) {
                const { assertPresent, inquirer, spinner } = Context.inject();
                assertPresent({ inquirer, spinner });
              
                if (config.projectId) {
              Severity: Minor
              Found in src/services/with-current-project.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 writeModel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                writeModel(config, table, fields, references, options = {}) {
                  const { underscored } = options;
                  let modelPath = `models/${this.tableToFilename(table)}.js`;
                  if (config.appConfig.useMultiDatabase) {
                    modelPath = `models/${config.appConfig.modelsExportPath}/${this.tableToFilename(table)}.js`;
              Severity: Minor
              Found in src/services/dumpers/forest-express.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 runAuthenticated has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                async runAuthenticated() {
                  const parsed = await this.parse(DeleteCommand);
                  const config = { ...this.env, ...parsed.flags, ...parsed.args };
                  const manager = new EnvironmentManager(config);
              
              
              Severity: Minor
              Found in src/commands/environments/delete.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 environmentVariablesAutoFilling has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                async environmentVariablesAutoFilling() {
                  if (this.environmentVariables.projectOrigin !== 'In-app') {
                    const existingEnvFile = this.fs.existsSync('.env');
                    const response = await this.inquirer.prompt([
                      {
              Severity: Minor
              Found in src/commands/init.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 buildDatabaseUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function buildDatabaseUrl(dbConfig: DbConfig): string | null {
                let connectionString: string;
              
                if (!dbConfig) {
                  return null;
              Severity: Minor
              Found in src/utils/database-url.ts - 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 runAuthenticated has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async runAuthenticated() {
                  const parsed = await this.parse(BranchCommand);
                  const envSecret = this.env.FOREST_ENV_SECRET;
                  const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
                  let config;
              Severity: Minor
              Found in src/commands/branch.js - About 1 hr to fix

                Function perform has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  this.perform = async table => {
                    const replacements = { table, schemaName: queryInterface.sequelize.config.database };
                    const query = `
                        SELECT DISTINCT
                            tableConstraints.constraint_type AS columnType,

                  Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render(environment, config) {
                      const table = new this.Table({
                        chars,
                      });
                  
                  
                  Severity: Minor
                  Found in src/renderers/environment.js - About 1 hr to fix

                    Function developmentEnvironmentCreation has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async developmentEnvironmentCreation() {
                        let developmentEnvironment;
                        try {
                          developmentEnvironment = await new ProjectManager(
                            this.config,
                    Severity: Minor
                    Found in src/commands/init.js - About 1 hr to fix

                      Function runAuthenticated has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async runAuthenticated() {
                          try {
                            const config = await this.getConfig();
                            const branches = (await BranchManager.getBranches(config.envSecret)) || [];
                      
                      
                      Severity: Minor
                      Found in src/commands/switch.js - About 1 hr to fix

                        Function ColumnTypeGetter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function ColumnTypeGetter(databaseConnection, schema, allowWarning = true) {
                          const queryInterface = databaseConnection.getQueryInterface();
                        
                          function isDialect(dialect) {
                            return queryInterface.sequelize.options.dialect === dialect;
                        Severity: Minor
                        Found in src/services/schema/update/analyzer/sequelize-column-type-getter.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 runAuthenticated has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          async runAuthenticated() {
                            const parsed = await this.parse(ResetCommand);
                            const envSecret = this.env.FOREST_ENV_SECRET;
                            const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
                            let config;
                        Severity: Minor
                        Found in src/commands/environments/reset.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

                        Severity
                        Category
                        Status
                        Source
                        Language