resource-watch/document-adapter

View on GitHub
app/src/services/scroll.js

Summary

Maintainability
D
2 days
Test Coverage
B
83%

Function init has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    async init() {
        logger.debug('Scroll init');
        this.timeoutFunc = setTimeout(() => {
            this.timeout = true;
        }, 60000);
Severity: Minor
Found in app/src/services/scroll.js - About 5 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 init has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async init() {
        logger.debug('Scroll init');
        this.timeoutFunc = setTimeout(() => {
            this.timeout = true;
        }, 60000);
Severity: Major
Found in app/src/services/scroll.js - About 3 hrs to fix

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

        convertDataToDownload(data, type, first, more, cloneUrl) {
            if (type === 'csv') {
                if (data.data.length === 0) {
                    return '';
                }
    Severity: Minor
    Found in app/src/services/scroll.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 continue has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        async continue() {
    
            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');
    Severity: Minor
    Found in app/src/services/scroll.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 convertDataToDownload has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        convertDataToDownload(data, type, first, more, cloneUrl) {
            if (type === 'csv') {
                if (data.data.length === 0) {
                    return '';
                }
    Severity: Minor
    Found in app/src/services/scroll.js - About 1 hr to fix

      Function continue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async continue() {
      
              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');
      Severity: Minor
      Found in app/src/services/scroll.js - About 1 hr 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

          There are no issues that match your filters.

          Category
          Status