resource-watch/doc-writer

View on GitHub

Showing 5 of 11 total issues

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 constructor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        constructor() {
            logger.info(`Connecting to Elasticsearch at ${elasticUrl}`);
    
            const elasticSearchConfig = {
                node: elasticUrl
    Severity: Minor
    Found in app/src/services/elastic.service.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

    Function saveBulk has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async saveBulk(index, data) {
    
            const exists = await new Promise((resolve, reject) => {
                logger.debug(`Checking if index ${index} exists`);
                this.elasticClient.indices.exists({ index }, (err, res) => {
    Severity: Major
    Found in app/src/services/elastic.service.js - About 2 hrs to fix

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

          constructor() {
              logger.info(`Connecting to Elasticsearch at ${elasticUrl}`);
      
              const elasticSearchConfig = {
                  node: elasticUrl
      Severity: Minor
      Found in app/src/services/elastic.service.js - About 1 hr to fix

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

            async consume(msg) {
                try {
                    logger.debug('Message received');
                    const message = JSON.parse(msg.content.toString());
                    await writerService.processMessage(message);
        Severity: Minor
        Found in app/src/services/data-queue.service.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