ForestAdmin/lumber

View on GitHub

Showing 53 of 79 total issues

Function handleSchema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  handleSchema() {
    if (this.isOptionRequested('dbSchema')) {
      this.envConfig.dbSchema = this.program.schema;
      if (!this.envConfig.dbSchema) {
        this.prompts.push({
Severity: Minor
Found in services/prompter/database-prompts.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 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 services/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 createReference has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

    Function loginWithGoogle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      async loginWithGoogle(email) {
        const endpoint = process.env.FOREST_URL && process.env.FOREST_URL.includes('localhost')
          ? 'http://localhost:4200' : 'https://app.forestadmin.com';
        const url = this.chalk.cyan.underline(`${endpoint}/authentication-token`);
        this.logger.info(`To authenticate with your Google account, please follow this link and copy the authentication token: ${url}`);
    Severity: Minor
    Found in services/authenticator.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 getDatabaseUrl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      static getDatabaseUrl(config) {
        let connectionString;
    
        if (config.dbConnectionUrl) {
          connectionString = config.dbConnectionUrl;
    Severity: Minor
    Found in services/dumper.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 handleEmail has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      handleEmail() {
        if (this.isOptionRequested('email')) {
          this.envConfig.email = this.program.email;
    
          if (!this.envConfig.email) {
    Severity: Minor
    Found in services/prompter/user-prompts.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 dump has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      async dump(schema, config) {
        const cwd = process.cwd();
        const projectPath = config.appName ? `${cwd}/${config.appName}` : cwd;
        const { isUpdate, useMultiDatabase, modelsExportPath } = config;
    
    
    Severity: Minor
    Found in services/dumper.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 ProjectCreator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function ProjectCreator(sessionToken) {
      this.createProject = async (projectName, config) => {
        try {
          const newProject = await api.createProject(config, sessionToken, { name: projectName });
    
    
    Severity: Minor
    Found in services/project-creator.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 loginFromCommandLine has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      async loginFromCommandLine(config) {
        const { email, token } = config;
        let sessionToken;
        try {
          sessionToken = token || this.fs.readFileSync(this.pathToLumberrc, { encoding: 'utf8' });
    Severity: Minor
    Found in services/authenticator.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(projectPath, { dbDialect, appName }) {
        const orm = dbDialect === 'mongodb' ? 'mongoose' : 'sequelize';
        const dependencies = {
          'body-parser': '1.19.0',
          chalk: '~1.1.3',
    Severity: Minor
    Found in services/dumper.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

    Avoid too many return statements within this function.
    Open

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

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

        connnectToSequelize(databaseDialect, options, isSSL) {
          let connectionOptionsSequelize = options.connectionOptions;
          if (!connectionOptionsSequelize) {
            connectionOptionsSequelize = {};
      
      
      Severity: Minor
      Found in services/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 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 services/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

      Severity
      Category
      Status
      Source
      Language