ForestAdmin/toolbelt

View on GitHub

Showing 91 of 172 total issues

Function createAllReferences has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createAllReferences(databaseSchema, schemaGenerated) {
  const references = {};
  Object.keys(databaseSchema).forEach(tableName => {
    references[tableName] = [];
  });
Severity: Major
Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.js - About 2 hrs to fix

    Function MysqlTableConstraintsGetter has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function MysqlTableConstraintsGetter(databaseConnection) {
      const queryInterface = databaseConnection.getQueryInterface();
    
      // NOTICE: provide an array of array. Each inner array representing a (possibly composite) unique
      //         index
    Severity: Minor
    Found in src/services/schema/update/analyzer/mysql-table-constraints-getter.js - About 2 hrs to fix

      Function runAuthenticated has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async runAuthenticated() {
          const parsed = await this.parse(DeleteCommand);
          const config = { ...this.env, ...parsed.flags, ...parsed.args };
          const manager = new EnvironmentManager(config);
      
      
      Severity: Minor
      Found in src/commands/environments/delete.js - About 1 hr to fix

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

          connectToMongodb(options, isSSL) {
            let connectionOptionsMongoClient = options.connectionOptions;
            if (!connectionOptionsMongoClient) {
              connectionOptionsMongoClient = {
                useNewUrlParser: true,
        Severity: Minor
        Found in src/services/schema/update/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 constructor has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor({
            assertPresent,
            logger,
            detectReferences,
            applyReferences,
        Severity: Minor
        Found in src/services/schema/update/analyzer/mongo-collections-analyzer.js - About 1 hr to fix

          Function writeModel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            writeModel(config, table, fields, references, options = {}) {
              const { underscored } = options;
              let modelPath = `models/${this.tableToFilename(table)}.js`;
              if (config.appConfig.useMultiDatabase) {
                modelPath = `models/${config.appConfig.modelsExportPath}/${this.tableToFilename(table)}.js`;
          Severity: Minor
          Found in src/services/dumpers/forest-express.js - About 1 hr to fix

            Function createFiles has 45 lines of code (exceeds 25 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 1 hr to fix

              Function runAuthenticated has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async runAuthenticated() {
                  const parsed = await this.parse(ResetCommand);
                  const envSecret = this.env.FOREST_ENV_SECRET;
                  const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
                  let config;
              Severity: Minor
              Found in src/commands/environments/reset.js - About 1 hr to fix

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

                  async analyzeMongoCollections(databaseConnection) {
                    const collections = await databaseConnection.collections();
                    if (collections.length === 0) {
                      this.restoreDefaultState();
                      throw new EmptyDatabaseError('no collections found', {
                Severity: Minor
                Found in src/services/schema/update/analyzer/mongo-collections-analyzer.js - About 1 hr to fix

                  Function mapCollection has 42 lines of code (exceeds 25 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 1 hr to fix

                    Function createProject has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      this.createProject = async (config, sessionToken, project) => {
                        let newProject;
                    
                        try {
                          newProject = await agent
                    Severity: Minor
                    Found in src/services/api.js - About 1 hr to fix

                      Function createReference has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function createReference(
                        tableName,
                        existingsReferences,
                        association,
                        foreignKey,
                      Severity: Minor
                      Found in src/services/schema/update/analyzer/sequelize-tables-analyzer.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 addObjectSchema has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function addObjectSchema(type, parentSchema, currentKey) {
                        const isTypeAnArray = Array.isArray(type);
                      
                        if (parentSchema[currentKey] !== undefined) {
                          if (areSchemaTypesMixed(parentSchema[currentKey], type)) {
                      Severity: Minor
                      Found in src/services/schema/update/analyzer/mongo-embedded-analyzer.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 ApimapSorter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function ApimapSorter(apimap) {
                        const { assertPresent, logger, lodash } = inject();
                        assertPresent({ logger, lodash });
                      
                        function sortArrayOfObjects(array) {
                      Severity: Minor
                      Found in src/services/apimap-sorter.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 createReference has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function SchemaSender has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function SchemaSender(serializedSchema, secret, authenticationToken, oclifExit) {
                          /**
                           * @function
                           * @returns {Promise<number | undefined>}
                           */
                        Severity: Minor
                        Found in src/services/schema-sender.js - About 1 hr to fix

                          Function runAuthenticated has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async runAuthenticated() {
                              const parsed = await this.parse(PushCommand);
                              const envSecret = this.env.FOREST_ENV_SECRET;
                              const commandOptions = { ...parsed.flags, ...parsed.args, envSecret };
                              let config;
                          Severity: Minor
                          Found in src/commands/push.js - About 1 hr to fix

                            Function constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              constructor(context) {
                                super(context);
                            
                                const {
                                  assertPresent,
                            Severity: Minor
                            Found in src/services/dumpers/forest-express.js - About 1 hr to fix

                              Function handleBranchError has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              async function handleBranchError(rawError) {
                                const { message, meta } = handleErrorWithMeta(rawError);
                                switch (message) {
                                  // NOTICE: When no env/project can be found through envSecret
                                  case 'Not Found':
                              Severity: Minor
                              Found in src/services/branch-manager.js - About 1 hr to fix

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

                                  this.perform = () => {
                                    const { env, logger } = Context.inject();
                                
                                    return agent
                                      .post(`${env.FOREST_SERVER_URL}/forest/apimaps`)
                                Severity: Minor
                                Found in src/services/schema-sender.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language