DeuxHuitHuit/algolia-webcrawler

View on GitHub

Showing 23 of 23 total issues

Function results has 134 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const results = _.map(urls, (url, index) => {
        console.log('Registered ' + url.url);
        const processResults = processOne({
            config,
            url,
Severity: Major
Found in app.js - About 5 hrs to fix

    Function processOneCallback has 122 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            }, function processOneCallback(error, record) {
                const id = urlCount + 1;
                if (!!error || !record) {
                    console.error('%d - Error! %s', id, error.message);
                    if (!!error && !error.retry) {
    Severity: Major
    Found in app.js - About 4 hrs to fix

      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

        File app.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env node
        
        /**
         * App
         */
        Severity: Minor
        Found in app.js - About 3 hrs to fix

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

          module.exports = (config) => {
              const url = config.url;
              const parsedUrl = !url ? null : URL.parse(url);
          
              if (!parsedUrl || !parsedUrl.hostname) {
          Severity: Major
          Found in lib/pingback.js - About 3 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

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

              module.exports = (config) => {
                  const url = config.url;
                  const parsedUrl = !url ? null : URL.parse(url);
              
                  if (!parsedUrl || !parsedUrl.hostname) {
              Severity: Minor
              Found in lib/pingback.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

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

                module.exports = (config, cb) => {
                    _.each(config.sitemaps, (sitemap) => {
                        const urls = [];
                        const parsedUrl = URL.parse(sitemap.url);
                        const httpOptions = {
                Severity: Major
                Found in lib/sitemap.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 send has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        const send = (data, cb) => {
                            if (data && data.result && data.action && data.url) {
                                const postData =  querystring.stringify({
                                    result: data.result,
                                    action: data.action,
                    Severity: Major
                    Found in lib/pingback.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 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 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 req has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                const req = client.request(httpOptions, (res) => {
                                    let data = '';
                                    
                                    res.setEncoding('utf8');
                                    
                        Severity: Minor
                        Found in lib/sitemap.js - About 1 hr to fix

                          Function displayErrorReport has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const displayErrorReport = () => {
                              console.log();
                              if (!errors.length) {
                                  console.log(chalk.green('No problem were reported during the crawl!'));
                              } else {
                          Severity: Minor
                          Found in app.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

                            Consider simplifying this complex logical expression.
                            Open

                                    if (data && data.result && data.action && data.url) {
                                        const postData =  querystring.stringify({
                                            result: data.result,
                                            action: data.action,
                                            url: data.url,
                            Severity: Major
                            Found in lib/pingback.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

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

                              module.exports = (config, cb) => {
                                  _.each(config.sitemaps, (sitemap) => {
                                      const urls = [];
                                      const parsedUrl = URL.parse(sitemap.url);
                                      const httpOptions = {
                              Severity: Minor
                              Found in lib/sitemap.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

                              Severity
                              Category
                              Status
                              Source
                              Language