ForestAdmin/lumber

View on GitHub

Showing 53 of 79 total issues

Function connectToMongodb has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  connectToMongodb(options, isSSL) {
    let connectionOptionsMongoClient = options.connectionOptions;
    if (!connectionOptionsMongoClient) {
      connectionOptionsMongoClient = {
        useNewUrlParser: true,
Severity: Minor
Found in services/database.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 createProject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  async createProject(config, sessionToken, project) {
    let newProject;

    try {
      newProject = await this.agent
Severity: Minor
Found in services/api.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 writePackageJson has 35 lines of code (exceeds 25 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 1 hr to fix

    Function createReference has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createReference(
      tableName,
      existingsReferences,
      association,
      foreignKey,
    Severity: Minor
    Found in services/analyzer/sequelize-tables-analyzer.js - About 1 hr to fix

      Function mapCollection has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function mapCollection() {
        function allItemsAreObjectIDs(array) {
          if (!array.length) return false;
          var itemToCheckCount = array.length > 3 ? 3 : array.length;
          var arrayOfObjectIDs = true;
      Severity: Minor
      Found in services/analyzer/mongo-collections-analyzer.js - About 1 hr to fix

        Function handleHostname has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          handleHostname() {
            if (this.isOptionRequested('appHostname')) {
              this.envConfig.appHostname = this.program.applicationHost;
              if (!this.envConfig.appHostname) {
                this.prompts.push({
        Severity: Minor
        Found in services/prompter/application-prompts.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 createAccount has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          async createAccount() {
            this.logger.info('Create an account:');
            const authConfig = await this.inquirer.prompt([{
              type: 'input',
              name: 'firstName',
        Severity: Minor
        Found in services/authenticator.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(projectPath, config, table, fields, references, options = {}) {
            const { underscored } = options;
            let modelPath = `models/${Dumper.tableToFilename(table)}.js`;
            if (config.useMultiDatabase) {
              modelPath = `models/${config.modelsExportPath}/${Dumper.tableToFilename(table)}.js`;
        Severity: Minor
        Found in services/dumper.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 add has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          add(key, options, promise = null) {
            spinnies.add(key, options);
        
            const spinner = {
              succeed(succeedOptions) {
        Severity: Minor
        Found in services/spinners.js - About 1 hr to fix

          Function analyzeMongoCollections has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function analyzeMongoCollections(databaseConnection) {
            const schema = {};
          
            return databaseConnection.collections()
              .then(async (collections) => {
          Severity: Minor
          Found in services/analyzer/mongo-collections-analyzer.js - About 1 hr to fix

            Function loginWithEmailOrTokenArgv has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async loginWithEmailOrTokenArgv(config) {
                try {
                  const { email, token } = config;
                  let { password } = config;
            
            
            Severity: Minor
            Found in services/authenticator.js - About 1 hr to fix

              Function ColumnTypeGetter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function ColumnTypeGetter(databaseConnection, schema, allowWarning = true) {
                const queryInterface = databaseConnection.getQueryInterface();
              
                function isDialect(dialect) {
                  return queryInterface.sequelize.options.dialect === dialect;
              Severity: Minor
              Found in services/analyzer/sequelize-column-type-getter.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 handleSsl has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                handleSsl() {
                  if (this.isOptionRequested('ssl')) {
                    const { ssl } = this.program;
                    if (ssl) {
                      try {
              Severity: Minor
              Found in services/prompter/database-prompts.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 handleSsl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                handleSsl() {
                  if (this.isOptionRequested('ssl')) {
                    const { ssl } = this.program;
                    if (ssl) {
                      try {
              Severity: Minor
              Found in services/prompter/database-prompts.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 services/analyzer/sequelize-tables-analyzer.js - About 1 hr to fix

                  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 services/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'; }
                        if (dbConnectionUrl.startsWith('mysql://')) { return 'mysql'; }
                        if (dbConnectionUrl.startsWith('mssql://')) { return 'mssql'; }
                  Severity: Minor
                  Found in services/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 loginWithEmailOrTokenArgv has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async loginWithEmailOrTokenArgv(config) {
                      try {
                        const { email, token } = config;
                        let { password } = config;
                  
                  
                  Severity: Minor
                  Found in services/authenticator.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 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

                  Severity
                  Category
                  Status
                  Source
                  Language