ForestAdmin/lumber

View on GitHub

Showing 79 of 79 total issues

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;
Severity: Minor
Found in services/analyzer/sequelize-table-constraints-getter.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 handlePort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  handlePort() {
    if (this.isOptionRequested('dbPort')) {
      this.prompts.push({
        type: 'input',
        name: 'dbPort',
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 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

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

      if (alias.endsWith('Uuid') && alias.length > 4) {
        return alias.substring(0, alias.length - 4);
      }
    Severity: Minor
    Found in services/analyzer/sequelize-tables-analyzer.js and 1 other location - About 35 mins to fix
    services/analyzer/sequelize-tables-analyzer.js on lines 125..127

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

    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

      if (alias.endsWith('Id') && alias.length > 2) {
        return alias.substring(0, alias.length - 2);
      }
    Severity: Minor
    Found in services/analyzer/sequelize-tables-analyzer.js and 1 other location - About 35 mins to fix
    services/analyzer/sequelize-tables-analyzer.js on lines 128..130

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

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

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

    const persons = [
      {
        _id: ObjectID(),
        name: 'James Cameron',
        propGroup: {
    Severity: Minor
    Found in test-fixtures/mongo/nested-object-model.js and 1 other location - About 35 mins to fix
    test-fixtures/mongo/deep-nested-model.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 46.

    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

              arrayWithComplexObject: [
                {
                  _id: ObjectID(),
                  name: 'Françis',
                  propGroup: {
    Severity: Minor
    Found in test-fixtures/mongo/deep-nested-model.js and 1 other location - About 35 mins to fix
    test-fixtures/mongo/nested-object-model.js on lines 3..14

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

    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

    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