shadowbq/domainatrix

View on GitHub

Showing 7 of 7 total issues

Method parse_domains_from_host has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_domains_from_host(host)
      return {} unless host

      parts = host.split(".").reverse
      ip_address = false
Severity: Minor
Found in lib/domainatrix/domain_parser.rb - About 3 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

Method parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(url)
      return {} unless url && url.strip != ''

      url = "http://#{url}" unless url[/:\/\//]
      url = url.downcase
Severity: Minor
Found in lib/domainatrix/domain_parser.rb - 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

Method parse_domains_from_host has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_domains_from_host(host)
      return {} unless host

      parts = host.split(".").reverse
      ip_address = false
Severity: Minor
Found in lib/domainatrix/domain_parser.rb - About 1 hr to fix

    Method read_dat_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_dat_file(file_name)
          # If we're in 1.9, make sure we're opening it in UTF-8
          if RUBY_VERSION >= '1.9'
            dat_file = File.open(file_name, "r:UTF-8")
          else
    Severity: Minor
    Found in lib/domainatrix/domain_parser.rb - 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

    Method parse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse(url)
          return {} unless url && url.strip != ''
    
          url = "http://#{url}" unless url[/:\/\//]
          url = url.downcase
    Severity: Minor
    Found in lib/domainatrix/domain_parser.rb - About 1 hr to fix

      Method scan has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.scan(text, &block)
          return [] unless text
          @schemes ||= %w(http https)
          all_trailing_clutter = /[.,:);]+$/
          clutter_without_parens = /[.,:);]+$/
      Severity: Minor
      Found in lib/domainatrix.rb - 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

      Method to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_s
            if @scheme.nil? || @scheme.empty?
              scheme = ''
            else
              scheme = "#{@scheme}://"
      Severity: Minor
      Found in lib/domainatrix/url.rb - 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

      Severity
      Category
      Status
      Source
      Language