ForestAdmin/toolbelt

View on GitHub

Showing 91 of 172 total issues

Avoid too many return statements within this function.
Open

  if (url?.startsWith('mysql://') || url?.startsWith('mariadb://')) return 'mysql';
Severity: Major
Found in src/services/projects/create/options.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return dbDialect;
    Severity: Major
    Found in src/services/schema/update/database.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return null;
      Severity: Major
      Found in src/services/projects/create/options.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return undefined;
        Severity: Major
        Found in src/services/projects/create/options.ts - About 30 mins to fix

          Function parseMsSql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            parseMsSql() {
              // Remove wrapping parentheses
              while (/^\(.*\)$/.test(this.expression)) {
                this.expression = this.expression.substr(1, this.expression.length - 2);
              }
          Severity: Minor
          Found in src/services/schema/update/analyzer/sequelize-default-value.js - About 25 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 writeDockerCompose has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            writeDockerCompose(config) {
              const databaseUrl = `\${${this.isLinuxOs ? 'DATABASE_URL' : 'DOCKER_DATABASE_URL'}}`;
              const forestUrl = this.env.FOREST_URL_IS_DEFAULT
                ? false
                : `\${FOREST_URL-${this.env.FOREST_SERVER_URL}}`;
          Severity: Minor
          Found in src/services/dumpers/forest-express.js - About 25 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 createFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            async createFiles(config, schema) {
              const { isUpdate, useMultiDatabase, modelsExportPath } = config.appConfig;
          
              await this.mkdirp(`${this.projectPath}/routes`);
              await this.mkdirp(`${this.projectPath}/forest`);
          Severity: Minor
          Found in src/services/dumpers/forest-express.js - About 25 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 connectToSequelize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            connectToSequelize(databaseDialect, options, isSSL) {
              let connectionOptionsSequelize = options.connectionOptions;
              if (!connectionOptionsSequelize) {
                connectionOptionsSequelize = {};
          
          
          Severity: Minor
          Found in src/services/schema/update/database.js - About 25 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 handleDatabaseUrlConfiguration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            async handleDatabaseUrlConfiguration() {
              if (this.environmentVariables.projectOrigin !== 'In-app') {
                const isDatabaseAlreadyConfigured = !!this.env.DATABASE_URL;
          
                if (!isDatabaseAlreadyConfigured) {
          Severity: Minor
          Found in src/commands/init.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
          Open

          export function getDialect(options: ProjectCreateOptions): ProjectCreateOptions['databaseDialect'] {
            const { databaseDialect: dialect, databaseConnectionURL: url } = options;
          
            if (dialect) return dialect;
            if (url?.startsWith('postgres://')) return 'postgres';
          Severity: Minor
          Found in src/services/projects/create/options.ts - About 25 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 ProjectManager has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function ProjectManager(config) {
            const { assertPresent, authenticator, env, jwtDecode, lodash } = Context.inject();
            assertPresent({ authenticator, env, jwtDecode, lodash });
          
            function deserialize(response) {
          Severity: Minor
          Found in src/services/project-manager.js - About 25 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