crawlkit/crawlkit

View on GitHub

Showing 17 of 22 total issues

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 exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = (scope, logger, finder, finderParameters, addUrl) => (cb) => {
        logger.debug('Trying to run finder.');
        if (!finder) {
          logger.debug('No finder defined.');
          cb();
      Severity: Major
      Found in src/worker/steps/findLinks.js - About 2 hrs to fix

        CrawlKit has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class CrawlKit {
        
          /**
           * Create a CrawlKit instance
           * @constructor
        Severity: Minor
        Found in src/index.js - About 2 hrs to fix

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

          module.exports = (crawlerInstance, writeResult, runnerKey, finderKey) => {
            const suffix = crawlerInstance.name ? `:${crawlerInstance.name}` : '';
            const prefix = `crawlkit${suffix}`;
            const logger = l(prefix);
            logger.info(`
          Severity: Major
          Found in src/crawl.js - About 2 hrs to fix

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

            module.exports = (scope, logger, finder, finderParameters, addUrl) => (cb) => {
              logger.debug('Trying to run finder.');
              if (!finder) {
                logger.debug('No finder defined.');
                cb();
            Severity: Minor
            Found in src/worker/steps/findLinks.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 exports has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (scope, logger, addUrl, crawlerInstance) => {
              const followRedirects = crawlerInstance.followRedirects;
              const redirectFilter = crawlerInstance.redirectFilter;
            
              return (cb) => {
            Severity: Major
            Found in src/worker/steps/openPage.js - About 2 hrs to fix

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

              module.exports = (crawlerInstance, runnerKey, finderKey, prefix, pool, addUrl, processResult) => {
                /**
                 * Gets a finder definition of a {@link CrawlKit} instance.
                 *
                 * @private
              Severity: Major
              Found in src/worker/index.js - About 2 hrs to fix

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

                module.exports = (logger, crawlerInstance, prefix) => {
                  const poolDebug = {};
                  const concurrency = crawlerInstance.concurrency;
                  const phantomParameters = crawlerInstance.phantomParameters;
                  const browserCookies = crawlerInstance.browserCookies;
                Severity: Major
                Found in src/createPhantomPool.js - About 2 hrs to fix

                  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

                    Function create has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        create: (callback) => {
                          async.waterfall([
                            function createPhantom(done) {
                              logger.debug('Creating PhantomJS instance');
                              driver.create({
                    Severity: Minor
                    Found in src/createPhantomPool.js - About 1 hr to fix

                      Function phantomCallback has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function phantomCallback(err, urls) {
                          if (done.called) {
                            logger.debug('Callback alread called.');
                            return;
                          }
                      Severity: Minor
                      Found in src/worker/steps/findLinks.js - About 1 hr to fix

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

                        module.exports = (logger, crawlerInstance, prefix) => {
                          const poolDebug = {};
                          const concurrency = crawlerInstance.concurrency;
                          const phantomParameters = crawlerInstance.phantomParameters;
                          const browserCookies = crawlerInstance.browserCookies;
                        Severity: Minor
                        Found in src/createPhantomPool.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 onNavigationRequested has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            const onNavigationRequested = (redirectedToUrl, type, willNavigate, mainFrame) => {
                              if (urijs(scope.url).equals(redirectedToUrl)) {
                                // this is the initial open of the task URL, ignore
                                return;
                              }
                        Severity: Minor
                        Found in src/worker/steps/openPage.js - About 1 hr to fix

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

                          module.exports = (scope, logger, crawlerInstance) => {
                            const phantomPageSettings = crawlerInstance.phantomPageSettings;
                            const followRedirects = crawlerInstance.followRedirects;
                          
                            return (done) => {
                          Severity: Minor
                          Found in src/worker/steps/setPageSettings.js - About 1 hr to fix

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

                            module.exports = (trace) => {
                              if (!(trace instanceof Array)) {
                                return false;
                              }
                              for (let i = 0; i < trace.length; i += 1) {
                            Severity: Minor
                            Found in src/isPhantomError.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

                            Severity
                            Category
                            Status
                            Source
                            Language