crawlkit/crawlkit

View on GitHub
src/worker/steps/pageRunners.js

Summary

Maintainability
D
1 day
Test Coverage

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

module.exports = (scope, logger, runners, workerLogPrefix) => (cb) => {
  logger.debug('Trying to run page runners.');

  if (runners.size === 0) {
    logger.debug('No runners defined');
Severity: Major
Found in src/worker/steps/pageRunners.js - About 5 hrs to fix

    Function nextRunner has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const nextRunner = () => {
        if (done.called) {
          logger.debug('Callback was called already.');
          return;
        }
    Severity: Major
    Found in src/worker/steps/pageRunners.js - About 4 hrs to fix

      Function exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = (scope, logger, runners, workerLogPrefix) => (cb) => {
        logger.debug('Trying to run page runners.');
      
        if (runners.size === 0) {
          logger.debug('No runners defined');
      Severity: Minor
      Found in src/worker/steps/pageRunners.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 doneAndNext has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const doneAndNext = callbackTimeout(once((res) => {
            logger.debug(`Runner '${runnerId}' finished.`);
            let err;
            let result;
      
      
      Severity: Minor
      Found in src/worker/steps/pageRunners.js - About 1 hr to fix

        Unexpected chained assignment.
        Open

          const results = scope.result.runners = {}; // eslint-disable-line no-param-reassign
        Severity: Minor
        Found in src/worker/steps/pageRunners.js by eslint

        Disallow Use of Chained Assignment Expressions (no-multi-assign)

        Chaining the assignment of variables can lead to unexpected results and be difficult to read.

        a = b = c = d;

        Rule Details

        This rule disallows using multiple assignments within a single statement.

        Examples of incorrect code for this rule:

        /*eslint no-multi-assign: "error"*/
        
        var a = b = c = 5;
        
        var foo = bar = "baz";
        
        var a =
            b =
            c;

        Examples of correct code for this rule:

        /*eslint no-multi-assign: "error"*/
        var a = 5;
        var b = 5;
        var c = 5;
        
        var foo = "baz";
        var bar = "baz";
        
        var a = c;
        var b = c;

        Related Rules

        There are no issues that match your filters.

        Category
        Status