xiaody/adblock-minus

View on GitHub

Showing 13 of 15 total issues

Function fromText has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  static fromText (text) {
    let blocking = true

    if (text.indexOf('@@') === 0) {
      blocking = false
Severity: Minor
Found in lib/FilterClasses.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 calcDomains has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  calcDomains () {
    if (this.domainSource) {
      this.domains = new Map()
      let domains = this.domainSource.split(this.domainSeparator)
      if (domains.length === 1 && domains[0][0] !== '~') {
Severity: Minor
Found in lib/FilterClasses.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 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 fromText has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static fromText (text) {
        let blocking = true
    
        if (text.indexOf('@@') === 0) {
          blocking = false
    Severity: Minor
    Found in lib/FilterClasses.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 matchFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        matchFilter (location, contentType, docDomain) {
          let keywords = location.toLowerCase().match(/[a-z0-9%]{3,}/g) || []
          keywords.unshift('')
      
          let map = this.filterByKeyword
      Severity: Minor
      Found in lib/Blocker.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 findKeyword has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          findKeyword (filter) {
            let text = filter.regexpSrc
            let defaultResult = ''
        
            if (text.length > 2 && text.startsWith('/') && text.endsWith('/')) {
        Severity: Minor
        Found in lib/Blocker.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 isActiveOnDomain has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            isActiveOnDomain (docDomain = '') {
              if (this.domainSource) this.calcDomains()
              if (!this.domains) return true
              docDomain = docDomain.toUpperCase()
              let nextDot
          Severity: Minor
          Found in lib/FilterClasses.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

          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

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

            fromText (text = '') {
              text = text.trim()
              if (!text || text.startsWith('!') || text.includes('#@#')) return
              if (/^\[Adblock Plus/i.test(text)) return
          
          
          Severity: Minor
          Found in lib/FilterClasses.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

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

            * selectors (domain) {
              const hotSelectors = this._getSelectorsInHotfilters(domain)
              if (hotSelectors.length) {
                yield hotSelectors
              }
          Severity: Minor
          Found in lib/Blocker.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

          Severity
          Category
          Status
          Source
          Language