krateng/maloja

View on GitHub
auxiliary/chromium_scrobbler/maloja-scrobbler/background.js

Summary

Maintainability
B
6 hrs
Test Coverage

Function onTabUpdated has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function onTabUpdated(tabId, changeInfo, tab) {


    // still same page?
    //console.log("Update to tab " + tabId + "!")
Severity: Minor
Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.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 onTabUpdated has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function onTabUpdated(tabId, changeInfo, tab) {


    // still same page?
    //console.log("Update to tab " + tabId + "!")
Severity: Minor
Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.js - About 1 hr to fix

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

    function onInternalMessage(request,sender) {
        // message from settings menu
        if (request.type == "query") {
            answer = [];
            for (tabId in tabManagers) {
    Severity: Minor
    Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.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

    Avoid deeply nested control flow statements.
    Open

                            if (result["service_active_" + key]) {
                                console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
                                tabManagers[tabId] = new Controller(tabId,key);
                                updateTabNum();
                                //chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
    Severity: Major
    Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.js - About 45 mins to fix

      Function startPlayback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          startPlayback(artist,title,seconds) {
      
              // CASE 1: Resuming playback of previously played title
              if (artist == this.currentArtist && title == this.currentTitle && !this.currentlyPlaying) {
                  console.log("Resuming playback of " + this.currentTitle)
      Severity: Minor
      Found in auxiliary/chromium_scrobbler/maloja-scrobbler/background.js - About 35 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

      There are no issues that match your filters.

      Category
      Status