tk120404/node-rssparser

View on GitHub

Showing 17 of 26 total issues

Function parseURL has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

function parseURL(feedURL, options, callback) {
    if (typeof options === 'function' && !callback) {
        callback = options;
        options = {};
    }
Severity: Minor
Found in lib/feed.js - About 4 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 formatATOM has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function formatATOM(json, options) {
    var output = {
        'type': 'atom',
        items: []
    };
Severity: Major
Found in lib/feed.js - About 3 hrs to fix

    File feed.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    //feed.js
    var xml2js = require('xml2js'),
        _ = require('underscore'),
        request = require('request'),
        URL = require('url'),
    Severity: Minor
    Found in lib/feed.js - About 3 hrs to fix

      Function formatRSS has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function formatRSS(json, options) {
          var output = {
              'type': 'rss',
              items: []
          };
      Severity: Major
      Found in lib/feed.js - About 2 hrs to fix

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

        function formatATOM(json, options) {
            var output = {
                'type': 'atom',
                items: []
            };
        Severity: Minor
        Found in lib/feed.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 parseURL has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function parseURL(feedURL, options, callback) {
            if (typeof options === 'function' && !callback) {
                callback = options;
                options = {};
            }
        Severity: Minor
        Found in lib/feed.js - About 1 hr to fix

          Function distance_of_time_in_words has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              distance_of_time_in_words: function(to, from) {
                  var distance_in_seconds = ((to - from) / 1000);
                  var distance_in_minutes = Math.floor(distance_in_seconds / 60);
                  var tense = distance_in_seconds < 0 ? " from now" : " ago";
                  distance_in_minutes = Math.abs(distance_in_minutes);
          Severity: Minor
          Found in lib/feed.js - About 1 hr to fix

            Function distance_of_time_in_words has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                distance_of_time_in_words: function(to, from) {
                    var distance_in_seconds = ((to - from) / 1000);
                    var distance_in_minutes = Math.floor(distance_in_seconds / 60);
                    var tense = distance_in_seconds < 0 ? " from now" : " ago";
                    distance_in_minutes = Math.abs(distance_in_minutes);
            Severity: Minor
            Found in lib/feed.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 formatRSS has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function formatRSS(json, options) {
                var output = {
                    'type': 'rss',
                    items: []
                };
            Severity: Minor
            Found in lib/feed.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 parseString has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function parseString(xml, options, callback) {
                // we need to check that the input in not a null input
                if (xml.split('<').length >= 3) {
                    var parser = new xml2js.Parser({
                        trim: false,
            Severity: Minor
            Found in lib/feed.js - About 1 hr to fix

              Avoid too many return statements within this function.
              Open

                          return 'about ' + Math.floor(distance_in_minutes / 60) + ' hours' + tense;
              Severity: Major
              Found in lib/feed.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return 'about a year' + tense;
                Severity: Major
                Found in lib/feed.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return 'about a month' + tense;
                  Severity: Major
                  Found in lib/feed.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return Math.floor(distance_in_minutes / 43200) + ' months' + tense;
                    Severity: Major
                    Found in lib/feed.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return 'over ' + Math.floor(distance_in_minutes / 525960) + ' years';
                      Severity: Major
                      Found in lib/feed.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return 'a day' + tense;
                        Severity: Major
                        Found in lib/feed.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return Math.floor(distance_in_minutes / 1440) + ' days' + tense;
                          Severity: Major
                          Found in lib/feed.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language