ForestAdmin/toolbelt

View on GitHub

Showing 166 of 172 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  constructor({
    assertPresent,
    constants,
    database,
    databaseAnalyzer,
Severity: Major
Found in src/services/schema/schema-service.js and 1 other location - About 1 hr to fix
src/services/authenticator.js on lines 8..197

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          fail(options = this.currentSpinnerOptions) {
            if (!this.isRunning()) {
              throw Error('No spinner is running.');
            }
        
        
        Severity: Major
        Found in src/services/spinner.js and 1 other location - About 1 hr to fix
        src/services/spinner.js on lines 59..66

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          success(options = this.currentSpinnerOptions) {
            if (!this.isRunning()) {
              throw Error('No spinner is running.');
            }
        
        
        Severity: Major
        Found in src/services/spinner.js and 1 other location - About 1 hr to fix
        src/services/spinner.js on lines 69..76

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

        Function createFiles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected async createFiles(dumpConfig: Config, mongoSchema?: any) {
            this.writePackageJson(
              dumpConfig.language,
              dumpConfig.dbConfig.dbDialect,
              dumpConfig.appConfig.appName,
        Severity: Minor
        Found in src/services/dumpers/agent-nodejs.ts - About 1 hr to fix

          Function check has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            this.check = async jobId => {
              try {
                const jobResponse = await agent
                  .get(`${env.FOREST_SERVER_URL}/api/jobs/${jobId}`)
                  .set('Authorization', `Bearer ${authenticator.getAuthToken()}`)
          Severity: Minor
          Found in src/services/job-state-checker.js - About 1 hr to fix

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

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

              Function notifySuccess has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async notifySuccess() {
                  if (
                    !this.applicationName ||
                    !this.command ||
                    !this.sessionToken ||
              Severity: Minor
              Found in src/utils/event-sender.js - About 1 hr to fix

                Function analyzeFields has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function analyzeFields(queryInterface, tableName, config) {
                  const dialect = queryInterface.sequelize.getDialect();
                  let columnsByName;
                
                  // Workaround bug in sequelize/dialects/mysql/query-generator#describe
                Severity: Minor
                Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.js - About 1 hr to fix

                  Function writeTsConfigJson has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    writeTsConfigJson() {
                      this.writeFile(
                        'tsconfig.json',
                        `${JSON.stringify(
                          {
                  Severity: Minor
                  Found in src/services/dumpers/agent-nodejs.ts - About 1 hr to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          if (err.status === 404) {
                            this.logger.error(`Cannot find the environment ${this.chalk.bold(config.environmentId)}.`);
                            this.exit(1);
                          } else if (err.status === 403) {
                            this.logger.error(
                    Severity: Major
                    Found in src/commands/environments/delete.js and 1 other location - About 1 hr to fix
                    src/commands/environments/delete.js on lines 61..70

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 55.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                          } else if (err.status === 403) {
                            this.logger.error(
                              `You do not have the rights to delete environment ${this.chalk.bold(
                                config.environmentId,
                              )}.`,
                    Severity: Major
                    Found in src/commands/environments/delete.js and 1 other location - About 1 hr to fix
                    src/commands/environments/delete.js on lines 58..70

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 55.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                            this.logger.log(`${this.chalk.bold('ENVIRONMENTS')}`, ...table.toString().split('\n'));
                    Severity: Major
                    Found in src/renderers/environments.js and 4 other locations - About 55 mins to fix
                    src/renderers/branches.js on lines 35..35
                    src/renderers/environment.js on lines 43..43
                    src/renderers/project.js on lines 30..30
                    src/renderers/projects.js on lines 30..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                            this.logger.log(`${this.chalk.bold('BRANCHES')}`, ...table.toString().split('\n'));
                    Severity: Major
                    Found in src/renderers/branches.js and 4 other locations - About 55 mins to fix
                    src/renderers/environment.js on lines 43..43
                    src/renderers/environments.js on lines 38..38
                    src/renderers/project.js on lines 30..30
                    src/renderers/projects.js on lines 30..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                            this.logger.log(`${this.chalk.bold('PROJECT')}`, ...table.toString().split('\n'));
                    Severity: Major
                    Found in src/renderers/project.js and 4 other locations - About 55 mins to fix
                    src/renderers/branches.js on lines 35..35
                    src/renderers/environment.js on lines 43..43
                    src/renderers/environments.js on lines 38..38
                    src/renderers/projects.js on lines 30..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                            this.logger.log(`${this.chalk.bold('PROJECTS')}`, ...table.toString().split('\n'));
                    Severity: Major
                    Found in src/renderers/projects.js and 4 other locations - About 55 mins to fix
                    src/renderers/branches.js on lines 35..35
                    src/renderers/environment.js on lines 43..43
                    src/renderers/environments.js on lines 38..38
                    src/renderers/project.js on lines 30..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Severity
                    Category
                    Status
                    Source
                    Language