DeuxHuitHuit/algolia-webcrawler

View on GitHub
lib/process.js

Summary

Maintainability
D
2 days
Test Coverage

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

module.exports = (data, cb) => {
    const config = data.config;
    const plugins = data.plugins;
    const isRetry = !!data.isRetry;
    const url = data.url;
Severity: Major
Found in lib/process.js - About 4 hrs to fix

    Function fetch has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const fetch = () => {
            const shasum = crypto.createHash('sha1');
            shasum.update(url.url, 'utf8');
    
            if (action === 'delete') {
    Severity: Major
    Found in lib/process.js - About 2 hrs to fix

      File process.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Processes one url
       */
      
      'use strict';
      Severity: Minor
      Found in lib/process.js - About 2 hrs to fix

        Function req has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    var req = client.request(httpOptions, (res) => {
                        let data = '';
                        const now = new Date();
                        const meta = {
                            date: now,
        Severity: Major
        Found in lib/process.js - About 2 hrs to fix

          Function parse has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const parse = (record, data, config) => {
              const $ = cheerio.load(data);
              
              // Process all selectors
              _.each(config.selectors, (selector) => {
          Severity: Major
          Found in lib/process.js - About 2 hrs to fix

            Function recursiveFindValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            const recursiveFindValue = (node, array, attribs) => {
                if (!node || node.type === 'comment') {
                    return array;
                }
                
            Severity: Minor
            Found in lib/process.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 exports has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = (data, cb) => {
                const config = data.config;
                const plugins = data.plugins;
                const isRetry = !!data.isRetry;
                const url = data.url;
            Severity: Minor
            Found in lib/process.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 recursiveFindValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const recursiveFindValue = (node, array, attribs) => {
                if (!node || node.type === 'comment') {
                    return array;
                }
                
            Severity: Minor
            Found in lib/process.js - About 1 hr to fix

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

              const trimmer = (record, config) => {
                  const bytes = (s) => ~-encodeURI(s).split(/%..|./).length;
                  const jsonSize = (s) => bytes(JSON.stringify(s));
                  const limit = config.maxRecordSize;
                  const attributes = config.attributesToPop || defaultPoppedAttributes;
              Severity: Minor
              Found in lib/process.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

              There are no issues that match your filters.

              Category
              Status