resource-watch/document-adapter

View on GitHub

Showing 59 of 92 total issues

Avoid deeply nested control flow statements.
Open

                    if (el[name]) {
                        target[currentSelectElement.alias] = el[name];
                    }
Severity: Major
Found in app/src/serializers/jsonSerializer.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (exists) {
                                node.value = exists.value;
                            }
    Severity: Major
    Found in app/src/services/queryService.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (mapping[node.value] && mapping[node.value].type === 'text') {
                                  node.value = `${node.value}.keyword`;
                              }
      Severity: Major
      Found in app/src/services/queryService.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (el[name]) {
                                target[currentSelectElement.alias] = el[name];
                            }
        Severity: Major
        Found in app/src/serializers/csvSerializer.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for (let j = 0; j < node.arguments.length; j += 1) {
                                      if (node.arguments[j].type === 'literal' && mapping[node.arguments[j].value] && mapping[node.arguments[j].value].type === 'text') {
                                          node.arguments[j].value = `${node.arguments[j].value}.keyword`;
                                      }
                                  }
          Severity: Major
          Found in app/src/services/queryService.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (node.arguments[j].type === 'literal' && mapping[node.arguments[j].value] && mapping[node.arguments[j].value].type === 'text') {
                                        node.arguments[j].value = `${node.arguments[j].value}.keyword`;
                                    }
            Severity: Major
            Found in app/src/services/queryService.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (buckets[i][keys[j]].value) {
                                      obj[keys[j]] = buckets[i][keys[j]].value;
                                  }
              Severity: Major
              Found in app/src/serializers/csvSerializer.js - About 45 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if (this.resultScroll.aggregations) {
                            const data = Scroll.serialize(this.resultScroll, this.parsed, this.format);
                            this.stream.write(this.convertDataToDownload(data, this.format, true, false, this.cloneUrl), 'binary');
                        } else {
                            this.first = true;
                Severity: Major
                Found in app/src/services/scroll.js - About 40 mins to fix

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

                      static async query(ctx) {
                          logger.info('Do Query with dataset', ctx.request.body);
                          logger.debug('Checking if is delete or select');
                  
                          try {
                  Severity: Minor
                  Found in app/src/routes/api/v1/query.router.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 containApps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const containApps = (apps1, apps2) => {
                      if (!apps1 || !apps2) {
                          return false;
                      }
                      for (let i = 0, { length } = apps1; i < length; i += 1) {
                  Severity: Minor
                  Found in app/src/routes/api/v1/query.router.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 containApps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const containApps = (apps1, apps2) => {
                      if (!apps1 || !apps2) {
                          return false;
                      }
                      for (let i = 0, { length } = apps1; i < length; i += 1) {
                  Severity: Minor
                  Found in app/src/routes/api/v1/dataset.router.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 null;
                  Severity: Major
                  Found in app/src/serializers/csvSerializer.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return null;
                    Severity: Major
                    Found in app/src/serializers/jsonSerializer.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return null;
                      Severity: Major
                      Found in app/src/services/queryService.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return right;
                        Severity: Major
                        Found in app/src/services/queryService.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return {
                                          data: data.hits.hits.map((el) => {
                                              // eslint-disable-next-line no-underscore-dangle
                                              const formatted = CSVSerializer.formatAlias(Object.assign(el._source, {
                                                  _id: el._id
                          Severity: Major
                          Found in app/src/serializers/csvSerializer.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return {
                                            data: data.hits.hits.map((el) => {
                                                // eslint-disable-next-line no-underscore-dangle
                                                const formatted = JSONSerializer.formatAlias(Object.assign(el._source, {
                                                    _id: el._id
                            Severity: Major
                            Found in app/src/serializers/jsonSerializer.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return left;
                              Severity: Major
                              Found in app/src/services/queryService.js - About 30 mins to fix

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

                                    async sendMessage(msg, retryOnChannelClosed = true) {
                                        logger.info(`Sending message to ${this.q}`, msg);
                                        try {
                                            // Sending to queue
                                            await this.isInit;
                                Severity: Minor
                                Found in app/src/services/taskQueueService.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