xiaody/adblock-minus

View on GitHub
chrome/background.js

Summary

Maintainability
B
5 hrs
Test Coverage

Function onBeforeRequest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function onBeforeRequest (details) {
  let url = details.url.toLowerCase()
  let tabId = details.tabId
  let type = details.type

Severity: Minor
Found in chrome/background.js - About 1 hr to fix

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

    function onBeforeRequest (details) {
      let url = details.url.toLowerCase()
      let tabId = details.tabId
      let type = details.type
    
    
    Severity: Minor
    Found in chrome/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

    Function addRemote has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      addRemote (name, url) {
        return new Promise((resolve, reject) => {
          storage.get(url, (info) => {
            if (info[url]) {
              this.add(url, info[url].content)
    Severity: Minor
    Found in chrome/background.js - About 1 hr to fix

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

      function onBeforeSendHeaders (details) {
        let url = details.url.toLowerCase()
        let type = details.type
      
        if (type === 'main_frame') {
      Severity: Minor
      Found in chrome/background.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

      Function match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        match (url, type, documentHost) {
          if (this.isInWhitelist(documentHost)) return
          let ret = false
          for (const blocker of this.blockers.values()) {
            const code = blocker.matchStatus(url, type, documentHost)
      Severity: Minor
      Found in chrome/background.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

      There are no issues that match your filters.

      Category
      Status