wbio/reviews-collector-android

View on GitHub

Showing 8 of 342 total issues

Function collect has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    collect() {
        // Preserve our reference to 'this'
        const self = this;
        // Get a list of app IDs
        const appIds = _.keys(self.apps);
Severity: Minor
Found in src/index.js - About 7 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 collect has 135 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    collect() {
        // Preserve our reference to 'this'
        const self = this;
        // Get a list of app IDs
        const appIds = _.keys(self.apps);
Severity: Major
Found in src/index.js - About 5 hrs to fix

    File index.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const Crawler = require('node-webcrawler');
    const cheerio = require('cheerio');
    const _ = require('lodash');
    Severity: Minor
    Found in src/index.js - About 2 hrs to fix

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

              function parse(result) {
                  const html = responseToHtml(result);
                  if (typeof html === 'undefined') {
                      // We got an invalid response
                      requeue();
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

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

        function htmlToReviews(html, appId, pageNum, emit) {
            try {
                const $ = cheerio.load(html);
                const reviewObjs = $('.single-review');
                const reviews = [];
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

          Function constructor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              constructor(apps, options) {
                  if (options && options.maxPages && options.checkBeforeContinue) {
                      console.error('Warning: The \'maxPages\' option will be ignored when \'checkBeforeContinue\' is present');
                  }
                  const defaults = {
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

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

            function responseToHtml(response) {
                if (response.headers['content-type'] === 'application/json; charset=utf-8') {
                    try {
                        const decoded = decodeUnicode(decodeUTF8(response.body));
                        const body = JSON.parse(removeLeadingChars(decoded));
            Severity: Minor
            Found in src/index.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

            Avoid too many return statements within this function.
            Open

                return undefined;
            Severity: Major
            Found in src/index.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language