ForestAdmin/toolbelt

View on GitHub

Showing 166 of 172 total issues

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

  return agent
    .post(`${env.FOREST_SERVER_URL}/api/branches`)
    .set('Authorization', `Bearer ${authToken}`)
    .set('forest-secret-key', `${environmentSecret}`)
    .send({
Severity: Major
Found in src/services/branch-manager.js and 4 other locations - About 1 hr to fix
src/services/branch-manager.js on lines 75..79
src/services/branch-manager.js on lines 87..91
src/services/branch-manager.js on lines 99..103
src/services/environment-manager.js on lines 101..105

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 63.

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

    return agent
      .post(`${env.FOREST_SERVER_URL}/api/environments/reset`)
      .set('Authorization', `Bearer ${authToken}`)
      .set('forest-secret-key', `${environmentSecret}`)
      .send({ environmentName });
Severity: Major
Found in src/services/environment-manager.js and 4 other locations - About 1 hr to fix
src/services/branch-manager.js on lines 60..67
src/services/branch-manager.js on lines 75..79
src/services/branch-manager.js on lines 87..91
src/services/branch-manager.js on lines 99..103

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 63.

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 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

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

      return agent
        .post(`${env.FOREST_SERVER_URL}/api/branches/push`)
        .set('Authorization', `Bearer ${authToken}`)
        .set('forest-secret-key', `${environmentSecret}`)
        .send();
    Severity: Major
    Found in src/services/branch-manager.js and 4 other locations - About 1 hr to fix
    src/services/branch-manager.js on lines 60..67
    src/services/branch-manager.js on lines 87..91
    src/services/branch-manager.js on lines 99..103
    src/services/environment-manager.js on lines 101..105

    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 63.

    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

      return agent
        .post(`${env.FOREST_SERVER_URL}/api/branches/set-origin`)
        .set('Authorization', `Bearer ${authToken}`)
        .set('forest-secret-key', `${environmentSecret}`)
        .send({ originEnvironmentName: encodeURIComponent(originEnvironmentName) });
    Severity: Major
    Found in src/services/branch-manager.js and 4 other locations - About 1 hr to fix
    src/services/branch-manager.js on lines 60..67
    src/services/branch-manager.js on lines 75..79
    src/services/branch-manager.js on lines 87..91
    src/services/environment-manager.js on lines 101..105

    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 63.

    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 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

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

          const buildReference = (collectionName, referencedCollection, field) => {
            if (referencedCollection) {
              return {
                from: { collectionName, fieldName: field.name },
                to: { collectionName: referencedCollection },
          src/services/schema/update/analyzer/mongo-references-analyzer.js on lines 21..29

          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 60.

          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

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

          const buildReference = (collectionName, referencedCollection, field) => {
            if (referencedCollection) {
              return {
                from: { collectionName, fieldName: field.name },
                to: { collectionName: referencedCollection },
          src/services/schema/update/analyzer/mongo-hasmany-analyzer.js on lines 24..32

          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 60.

          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 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,

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

                  assertPresent({
                    constants,
                    database,
                    databaseAnalyzer,
                    forestExpressDumper,
              Severity: Major
              Found in src/services/schema/schema-service.js and 1 other location - About 1 hr to fix
              src/services/dumpers/forest-express.js on lines 27..38

              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

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

                  assertPresent({
                    env,
                    Sequelize,
                    Handlebars,
                    mkdirp,
              Severity: Major
              Found in src/services/dumpers/forest-express.js and 1 other location - About 1 hr to fix
              src/services/schema/schema-service.js on lines 17..28

              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

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

              function Authenticator({
                logger,
                api,
                chalk,
                inquirer,
              Severity: Major
              Found in src/services/authenticator.js and 1 other location - About 1 hr to fix
              src/services/schema/schema-service.js on lines 4..39

              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

              Severity
              Category
              Status
              Source
              Language