ForestAdmin/toolbelt

View on GitHub

Showing 91 of 172 total issues

Function TableConstraintsGetter has 292 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function TableConstraintsGetter(databaseConnection, schema) {
  const queryInterface = databaseConnection.getQueryInterface();

  this.perform = async table => {
    let query = null;

    Function perform has 289 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      this.perform = async table => {
        let query = null;
        const replacements = { table };
    
        switch (queryInterface.sequelize.options.dialect) {

      Function Authenticator has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

      function Authenticator({
        logger,
        api,
        chalk,
        inquirer,
      Severity: Minor
      Found in src/services/authenticator.js - About 1 day 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

      File sequelize-tables-analyzer.js has 443 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const { inject } = require('@forestadmin/context');
      const P = require('bluebird');
      const { plural, singular } = require('pluralize');
      const ColumnTypeGetter = require('./sequelize-column-type-getter');
      const DefaultValueExpression = require('./sequelize-default-value');
      Severity: Minor
      Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.js - About 6 hrs to fix

        Function ColumnTypeGetter has 134 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function ColumnTypeGetter(databaseConnection, schema, allowWarning = true) {
          const queryInterface = databaseConnection.getQueryInterface();
        
          function isDialect(dialect) {
            return queryInterface.sequelize.options.dialect === dialect;
        Severity: Major
        Found in src/services/schema/update/analyzer/sequelize-column-type-getter.js - About 5 hrs to fix

          Function mapCollection has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

          function mapCollection(keys = this, emitFunction, store) {
            // this block is to inject the emit function when this code is running locally
            var emitAction;
            if (emitFunction && store) {
              emitAction = function emit(key, value) {
          Severity: Minor
          Found in src/services/schema/update/analyzer/mongo-collections-analyzer.js - About 4 hrs 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

          File agent-nodejs.ts has 328 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type { Config, DbConfig } from '../../interfaces/project-create-interface';
          import type { Language } from '../../utils/languages';
          import type Strings from '../../utils/strings';
          import type Lodash from 'lodash';
          
          
          Severity: Minor
          Found in src/services/dumpers/agent-nodejs.ts - About 3 hrs to fix

            File forest-express.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const { URL } = require('url');
            const { plural, singular } = require('pluralize');
            const IncompatibleLianaForUpdateError = require('../../errors/dumper/incompatible-liana-for-update-error');
            const InvalidForestCLIProjectStructureError = require('../../errors/dumper/invalid-forest-cli-project-structure-error');
            const AbstractDumper = require('./abstract-dumper').default;
            Severity: Minor
            Found in src/services/dumpers/forest-express.js - About 3 hrs to fix

              Function EnvironmentManager has 96 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function EnvironmentManager(config) {
                const { assertPresent, authenticator, env, keyGenerator } = Context.inject();
                assertPresent({ authenticator, env, keyGenerator });
              
                this.listEnvironments = async () => {
              Severity: Major
              Found in src/services/environment-manager.js - About 3 hrs to fix

                File mongo-collections-analyzer.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                const P = require('bluebird');
                const { ObjectId } = require('mongodb');
                
                const EmptyDatabaseError = require('../../../../errors/database/empty-database-error');
                
                
                Severity: Minor
                Found in src/services/schema/update/analyzer/mongo-collections-analyzer.js - About 3 hrs to fix

                  Function SchemaSerializer has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function SchemaSerializer() {
                    // WARNING: Attributes declaration order is important for .forestadmin-schema.json format.
                    const options = {
                      id: 'name',
                      // TODO: Remove nameOld attribute once the lianas versions older than 2.0.0 are minority.
                  Severity: Major
                  Found in src/serializers/schema.js - About 3 hrs to fix

                    Function Api has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function Api({
                      pkg,
                      env,
                      superagent: agent,
                      applicationTokenSerializer,
                    Severity: Minor
                    Found in src/services/api.js - About 3 hrs 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 ApimapSorter has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function ApimapSorter(apimap) {
                      const { assertPresent, logger, lodash } = inject();
                      assertPresent({ logger, lodash });
                    
                      function sortArrayOfObjects(array) {
                    Severity: Major
                    Found in src/services/apimap-sorter.js - About 3 hrs to fix

                      File sequelize-table-constraints-getter.js has 296 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      const MysqlTableConstraintsGetter = require('./mysql-table-constraints-getter');
                      
                      function TableConstraintsGetter(databaseConnection, schema) {
                        const queryInterface = databaseConnection.getQueryInterface();
                      
                      

                        Function analyzeSequelizeTables has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function analyzeSequelizeTables(connection, config, allowWarning) {
                          const { assertPresent, lodash } = inject();
                          assertPresent({ lodash });
                        
                          // User provided a schema, check if it exists
                        Severity: Major
                        Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.js - About 2 hrs to fix

                          Function perform has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            this.perform = async (columnInfo, columnName, tableName) => {
                              const { logger } = Context.inject();
                              const { type } = columnInfo;
                          
                              switch (type) {
                          Severity: Major
                          Found in src/services/schema/update/analyzer/sequelize-column-type-getter.js - About 2 hrs to fix

                            Function JobStateChecker has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function JobStateChecker(message, oclifExit) {
                              const { assertPresent, authenticator, env, logger } = Context.inject();
                              assertPresent({ authenticator, env, logger });
                            
                              const bar = new ProgressBar(`${message} [:bar] :percent `, { total: 100 });
                            Severity: Minor
                            Found in src/services/job-state-checker.js - About 2 hrs 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

                            ForestExpress has 23 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class ForestExpress extends AbstractDumper {
                              templateFolder = 'forest-express';
                            
                              constructor(context) {
                                super(context);
                            Severity: Minor
                            Found in src/services/dumpers/forest-express.js - About 2 hrs to fix

                              Function readSchema has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                readSchema() {
                                  this.logger.log('Reading ".forestadmin-schema.json" from current directory...');
                                  const filename = '.forestadmin-schema.json';
                              
                                  if (!this.fs.existsSync(filename)) {
                              Severity: Major
                              Found in src/commands/schema/apply.js - About 2 hrs to fix

                                Function ProjectManager has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function ProjectManager(config) {
                                  const { assertPresent, authenticator, env, jwtDecode, lodash } = Context.inject();
                                  assertPresent({ authenticator, env, jwtDecode, lodash });
                                
                                  function deserialize(response) {
                                Severity: Major
                                Found in src/services/project-manager.js - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language