resource-watch/doc-orchestrator

View on GitHub

Showing 19 of 42 total issues

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

async function init() {
    return new Promise((resolve, reject) => {
        async function onDbReady(err) {
            if (err) {
                if (retries >= 0) {
Severity: Major
Found in app/src/app.js - About 2 hrs to fix

    Function onDbReady has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            async function onDbReady(err) {
                if (err) {
                    if (retries >= 0) {
                        retries -= 1;
                        logger.error(`Failed to connect to MongoDB uri ${mongoUri}, retrying...`);
    Severity: Major
    Found in app/src/app.js - About 2 hrs to fix

      File status-queue.service.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const logger = require('logger');
      const QueueService = require('services/queue.service');
      const TaskService = require('services/task.service');
      const DatasetService = require('services/dataset.service');
      const { execution, status, task } = require('rw-doc-importer-messages');
      Severity: Minor
      Found in app/src/services/status-queue.service.js - About 2 hrs to fix

        Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = (grunt) => {
        
            grunt.file.setBase('..');
            // eslint-disable-next-line import/no-extraneous-dependencies
            require('load-grunt-tasks')(grunt);
        Severity: Major
        Found in app/Gruntfile.js - About 2 hrs to fix

          Function getFilteredQuery has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static getFilteredQuery(query) {
                  const allowedSearchFields = {
                      type: 'type',
                      status: 'status',
                      datasetId: 'datasetId',
          Severity: Major
          Found in app/src/services/task.service.js - About 2 hrs to fix

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

                static serialize(data, link = null, skipLogs = false) {
                    const result = {};
                    if (data && Array.isArray(data) && data.length === 0) {
                        result.data = [];
                        return result;
            Severity: Minor
            Found in app/src/serializers/task.serializer.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 processMessage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async processMessage() {
            
                    switch (this.statusMsg.type) {
            
                        case status.MESSAGE_TYPES.STATUS_INDEX_DEACTIVATED:
            Severity: Minor
            Found in app/src/services/status-queue.service.js - About 1 hr to fix

              Function exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = (() => {
              
                  const loadAPI = (app, path, pathApi) => {
                      const routesFiles = fs.readdirSync(path);
                      let existIndexRouter = false;
              Severity: Minor
              Found in app/src/loader.js - About 1 hr to fix

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

                    async consume(msg) {
                        logger.info(`Message received in ${config.get('queues.tasks')}`);
                        this.taskMsg = JSON.parse(msg.content.toString());
                
                        // check if any task is currently running for this dataset
                Severity: Minor
                Found in app/src/services/tasks-queue.service.js - About 1 hr to fix

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

                      async indexCreated() {
                          const dataset = await DatasetService.get(this.currentTask.datasetId);
                          const { connectorUrl, sources } = dataset.data.attributes;
                  
                          const datasetProps = {
                  Severity: Minor
                  Found in app/src/services/status-queue.service.js - About 1 hr to fix

                    Function serialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static serialize(data, link = null, skipLogs = false) {
                            const result = {};
                            if (data && Array.isArray(data) && data.length === 0) {
                                result.data = [];
                                return result;
                    Severity: Minor
                    Found in app/src/serializers/task.serializer.js - About 1 hr to fix

                      Function loadAPI has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          const loadAPI = (app, path, pathApi) => {
                              const routesFiles = fs.readdirSync(path);
                              let existIndexRouter = false;
                              routesFiles.forEach((file) => {
                                  const newPath = path ? (`${path}/${file}`) : file;
                      Severity: Minor
                      Found in app/src/loader.js - About 1 hr to fix

                        Function importConfirmed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async importConfirmed() {
                                switch (this.currentTask.type) {
                        
                                    case task.MESSAGE_TYPES.TASK_OVERWRITE:
                                        await this.sendExecutionTask(execution.MESSAGE_TYPES.EXECUTION_DELETE_INDEX, [{ index: 'message.index' }]);
                        Severity: Minor
                        Found in app/src/services/status-queue.service.js - About 1 hr to fix

                          Function processMessage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async processMessage() {
                                  // Create the message
                                  let executorTaskMessage;
                                  // Adding taskId
                                  this.taskMsg.taskId = this.taskMsg.id;
                          Severity: Minor
                          Found in app/src/services/tasks-queue.service.js - About 1 hr to fix

                            Function getAll has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                static async getAll(query = {}) {
                                    logger.debug(`[TaskService]: Getting all tasks`);
                            
                                    const page = query['page[number]'] ? parseInt(query['page[number]'], 10) : 1;
                                    const limit = query['page[size]'] ? parseInt(query['page[size]'], 10) : 10;
                            Severity: Minor
                            Found in app/src/services/task.service.js - About 1 hr to fix

                              Function consume has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  async consume(msg) {
                                      logger.info(`Message received in ${config.get('queues.tasks')}`);
                                      this.taskMsg = JSON.parse(msg.content.toString());
                              
                                      // check if any task is currently running for this dataset
                              Severity: Minor
                              Found in app/src/services/tasks-queue.service.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 exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                              module.exports = (() => {
                              
                                  const loadAPI = (app, path, pathApi) => {
                                      const routesFiles = fs.readdirSync(path);
                                      let existIndexRouter = false;
                              Severity: Minor
                              Found in app/src/loader.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 indexCreated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  async indexCreated() {
                                      const dataset = await DatasetService.get(this.currentTask.datasetId);
                                      const { connectorUrl, sources } = dataset.data.attributes;
                              
                                      const datasetProps = {
                              Severity: Minor
                              Found in app/src/services/status-queue.service.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 init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  async init(consume) {
                                      let conn = null;
                                      while (connectAttempts >= 0 && conn === null) {
                                          try {
                                              // eslint-disable-next-line no-await-in-loop
                              Severity: Minor
                              Found in app/src/services/queue.service.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