olsh/Feedly-Notifier

View on GitHub
src/scripts/core.js

Summary

Maintainability
C
1 day
Test Coverage

File core.js has 860 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

"use strict";

var appGlobal = {
    feedlyApiClient: new FeedlyApiClient(),
    icons: {
Severity: Major
Found in src/scripts/core.js - About 2 days to fix

    Function parseFeeds has 100 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

    function parseFeeds(feedlyResponse) {
    
        return getUserSubscriptions()
            .then(function (subscriptionResponse) {
    
    
    Severity: Major
    Found in src/scripts/core.js - About 4 hrs to fix

      Function updateFeeds has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

      function updateFeeds(silentUpdate) {
          appGlobal.cachedFeeds = [];
          appGlobal.options.filters = appGlobal.options.filters || [];
      
          let streamIds = appGlobal.options.isFiltersEnabled && appGlobal.options.filters.length
      Severity: Major
      Found in src/scripts/core.js - About 2 hrs to fix

        Function sendDesktopNotification has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Wontfix

        function sendDesktopNotification(feeds) {
        
            //if notifications too many, then to show only count
            let maxNotifications = appGlobal.options.maxNotificationsCount;
            // @if BROWSER='firefox'
        Severity: Minor
        Found in src/scripts/core.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 sendDesktopNotification has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

        function sendDesktopNotification(feeds) {
        
            //if notifications too many, then to show only count
            let maxNotifications = appGlobal.options.maxNotificationsCount;
            // @if BROWSER='firefox'
        Severity: Major
        Found in src/scripts/core.js - About 2 hrs to fix

          Function makeMarkersRequest has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

          function makeMarkersRequest(parameters){
              apiRequestWrapper("markers/counts", {
                  parameters: parameters
              }).then(function (response) {
                  let unreadCounts = response.unreadcounts;
          Severity: Minor
          Found in src/scripts/core.js - About 1 hr to fix

            Function getAccessToken has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Wontfix

            function getAccessToken(callback) {
                let state = (new Date()).getTime();
                let redirectUri = "https://olsh.github.io/Feedly-Notifier/";
                let url = appGlobal.feedlyApiClient.getMethodUrl("auth/auth", {
                    response_type: "code",
            Severity: Minor
            Found in src/scripts/core.js - About 1 hr to fix

              Function toggleSavedFeed has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Wontfix

              function toggleSavedFeed(feedsIds, saveFeed, callback) {
                  if (saveFeed) {
                      apiRequestWrapper("tags/" + encodeURIComponent(appGlobal.savedGroup), {
                          method: "PUT",
                          body: {
              Severity: Minor
              Found in src/scripts/core.js - About 1 hr to fix

                Function markAsRead has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Wontfix

                function markAsRead(feedIds, callback) {
                
                    // We should copy the array due to aggressive GC in Firefox
                    // When the popup is closed Firefox destroys all objects created there
                    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Dead_object
                Severity: Minor
                Found in src/scripts/core.js - About 1 hr to fix

                  Function processCode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Wontfix

                              chrome.tabs.onUpdated.addListener(function processCode(tabId, information, tab) {
                                  let checkStateRegex = new RegExp("state=" + state);
                                  if (!checkStateRegex.test(information.url)) {
                                      return;
                                  }
                  Severity: Minor
                  Found in src/scripts/core.js - About 1 hr to fix

                    Function toggleSavedFeed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Wontfix

                    function toggleSavedFeed(feedsIds, saveFeed, callback) {
                        if (saveFeed) {
                            apiRequestWrapper("tags/" + encodeURIComponent(appGlobal.savedGroup), {
                                method: "PUT",
                                body: {
                    Severity: Minor
                    Found in src/scripts/core.js - About 45 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 -1;
                    Severity: Major
                    Found in src/scripts/core.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return 1;
                      Severity: Major
                      Found in src/scripts/core.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                return 0;
                        Severity: Major
                        Found in src/scripts/core.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                              return -1;
                          Severity: Major
                          Found in src/scripts/core.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                return 0;
                            Severity: Major
                            Found in src/scripts/core.js - About 30 mins to fix

                              Function setBadgeCounter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Wontfix

                              function setBadgeCounter(unreadFeedsCount) {
                                  if (appGlobal.options.showCounter) {
                                      chrome.browserAction.setBadgeText({ text: String(+unreadFeedsCount > 0 ? unreadFeedsCount : "")});
                                  } else {
                                      chrome.browserAction.setBadgeText({ text: ""});
                              Severity: Minor
                              Found in src/scripts/core.js - About 25 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

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

                                      get expandedPopupWidth() {
                                          let maxValue = 750;
                                          let minValue = 380;
                                          if (this._expandedPopupWidth > maxValue ) {
                                              return maxValue;
                              Severity: Major
                              Found in src/scripts/core.js and 1 other location - About 1 hr to fix
                              src/scripts/core.js on lines 62..72

                              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 65.

                              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

                                      get popupWidth() {
                                          let maxValue = 750;
                                          let minValue = 380;
                                          if (this._popupWidth > maxValue ) {
                                              return maxValue;
                              Severity: Major
                              Found in src/scripts/core.js and 1 other location - About 1 hr to fix
                              src/scripts/core.js on lines 76..86

                              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 65.

                              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 (a.date > b.date) {
                                                      return 1;
                                                  } else if (a.date < b.date){
                                                      return -1;
                                                  } else {
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 55 mins to fix
                              src/scripts/core.js on lines 608..614

                              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 54.

                              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 (a.engagementRate < b.engagementRate) {
                                                  return 1;
                                              } else if (a.engagementRate > b.engagementRate){
                                                  return -1;
                                              } else {
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 55 mins to fix
                              src/scripts/core.js on lines 599..605

                              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 54.

                              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

                                      apiRequestWrapper("tags/" + encodeURIComponent(appGlobal.savedGroup) + "/" + encodeURIComponent(feedsIds), {
                                          method: "DELETE"
                                      }).then(function () {
                                          if (typeof callback === "function") {
                                              callback(true);
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 55 mins to fix
                              src/scripts/core.js on lines 873..886

                              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 53.

                              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

                                      apiRequestWrapper("tags/" + encodeURIComponent(appGlobal.savedGroup), {
                                          method: "PUT",
                                          body: {
                                              entryIds: feedsIds
                                          }
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 55 mins to fix
                              src/scripts/core.js on lines 888..898

                              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 53.

                              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 (appGlobal.options.showFullFeedContent) {
                                                  if (item.content !== undefined) {
                                                      content = item.content.content;
                                                      contentDirection = item.content.direction;
                                                  }
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 40 mins to fix
                              src/scripts/core.js on lines 673..678

                              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 49.

                              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 (!content) {
                                                  if (item.summary !== undefined) {
                                                      content = item.summary.content;
                                                      contentDirection = item.summary.direction;
                                                  }
                              Severity: Minor
                              Found in src/scripts/core.js and 1 other location - About 40 mins to fix
                              src/scripts/core.js on lines 666..671

                              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 49.

                              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

                              There are no issues that match your filters.

                              Category
                              Status