tk120404/node-rssparser

View on GitHub

Showing 26 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val.published) {
                              //lets try basis js date parsing for now
                              obj.published_at = Date.parse(val.published[0]);
                              obj.time_ago = DateHelper.time_ago_in_words(obj.published_at);
                          }
              Severity: Major
              Found in lib/feed.js and 1 other location - About 1 hr to fix
              lib/feed.js on lines 167..171

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 56.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val.pubDate) {
                              //lets try basis js date parsing for now
                              obj.published_at = Date.parse(val.pubDate[0]);
                              obj.time_ago = DateHelper.time_ago_in_words(obj.published_at);
                          }
              Severity: Major
              Found in lib/feed.js and 1 other location - About 1 hr to fix
              lib/feed.js on lines 283..287

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 56.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val['media:thumbnail']) {
                              obj.media = val.media || {};
                              obj.media.thumbnail = val['media:thumbnail'];
                          }
              Severity: Minor
              Found in lib/feed.js and 1 other location - About 50 mins to fix
              lib/feed.js on lines 292..295

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 52.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val['media:thumbnail']) {
                              obj.media = val.media || {};
                              obj.media.thumbnail = val['media:thumbnail'];
                          }
              Severity: Minor
              Found in lib/feed.js and 1 other location - About 50 mins to fix
              lib/feed.js on lines 194..197

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 52.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val['media:content']) {
                              obj.media = val.media || {};
                              obj.media.content = val['media:content'];
                          }
              Severity: Minor
              Found in lib/feed.js and 1 other location - About 45 mins to fix
              lib/feed.js on lines 190..193

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                          if (val['media:content']) {
                              obj.media = val.media || {};
                              obj.media.content = val['media:content'];
                          }
              Severity: Minor
              Found in lib/feed.js and 1 other location - About 45 mins to fix
              lib/feed.js on lines 288..291

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                          obj.title = (_ref = val.title) != undefined && _ref.length > 0 ? _ref[0] : void 0;
              Severity: Minor
              Found in lib/feed.js and 2 other locations - About 35 mins to fix
              lib/feed.js on lines 159..159
              lib/feed.js on lines 160..160

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                          obj.summary = (_ref = val.description) != undefined && _ref.length > 0 ? _ref[0] : void 0;
              Severity: Minor
              Found in lib/feed.js and 2 other locations - About 35 mins to fix
              lib/feed.js on lines 158..158
              lib/feed.js on lines 160..160

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                          obj.url = (_ref = val.link) != undefined && _ref.length > 0 ? _ref[0] : void 0;
              Severity: Minor
              Found in lib/feed.js and 2 other locations - About 35 mins to fix
              lib/feed.js on lines 158..158
              lib/feed.js on lines 159..159

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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
                Severity
                Category
                Status
                Source
                Language