ForestAdmin/toolbelt

View on GitHub

Showing 91 of 172 total issues

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

              Function render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                render(environment, config) {
                  const table = new this.Table({
                    chars,
                  });
              
              
              Severity: Minor
              Found in src/renderers/environment.js - About 55 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 parseGeneric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                parseGeneric() {
                  const nulls = ['NULL'];
                  const falses = ['false', 'FALSE', "b'0'", '((0))'];
                  const trues = ['true', 'TRUE', "b'1'", '((1))'];
                  const isDate = ['TIMESTAMP', 'DATETIME', 'DATE', 'TIME'];
              Severity: Minor
              Found in src/services/schema/update/analyzer/sequelize-default-value.js - About 55 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 getDialect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                getDialect(dbConnectionUrl, dbDialect) {
                  if (dbConnectionUrl) {
                    if (dbConnectionUrl.startsWith('postgres://')) {
                      return 'postgres';
                    }
              Severity: Minor
              Found in src/services/schema/update/database.js - About 55 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 runAuthenticated has a Cognitive Complexity of 9 (exceeds 5 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 55 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 optionToInquirer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function optionToInquirer(name: string, option: CommandOptions[string]): unknown {
                const { os } = inject() as any; // eslint-disable-line @typescript-eslint/no-explicit-any
              
                // Use rawlist on windows because of https://github.com/SBoudrias/Inquirer.js/issues/303
                const listType = /^win/.test(os.platform()) ? 'rawlist' : 'list';
              Severity: Minor
              Found in src/utils/option-parser.ts - About 55 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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                parse() {
                  if (this.expression === null || this.expression === undefined) {
                    return null;
                  }
              
              
              Severity: Minor
              Found in src/services/schema/update/analyzer/sequelize-default-value.js - About 45 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 runAuthenticated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                async runAuthenticated() {
                  const parsed = await this.parse(PushCommand);
                  const envSecret = this.env.FOREST_ENV_SECRET;
                  const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
                  let config;
              Severity: Minor
              Found in src/commands/push.js - About 45 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 TableConstraintsGetter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function TableConstraintsGetter(databaseConnection, schema) {
                const queryInterface = databaseConnection.getQueryInterface();
              
                this.perform = async table => {
                  let query = null;

              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 8 (exceeds 5 allowed). Consider refactoring.
              Open

                async runAuthenticated() {
                  const parsed = await this.parse(CreateCommand);
                  const config = await withCurrentProject({ ...this.env, ...parsed.flags });
                  const manager = new EnvironmentManager(config);
              
              
              Severity: Minor
              Found in src/commands/environments/create.js - About 45 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 createReference has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                tableName,
                existingsReferences,
                association,
                foreignKey,
                manyToManyForeignKey,
              Severity: Minor
              Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.js - About 35 mins to fix

                Function runAuthenticated has a Cognitive Complexity of 7 (exceeds 5 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 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(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 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 notifyError has a Cognitive Complexity of 7 (exceeds 5 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 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 _logLine has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  _logLine(message, options) {
                    if (this.silent) return;
                
                    options = {
                      ...DEFAULT_OPTION_VALUES,
                Severity: Minor
                Found in src/services/logger.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

                Severity
                Category
                Status
                Source
                Language