yhirose/maxminddb

View on GitHub

Showing 5 of 5 total issues

Method decode has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def decode(pos, base_pos)
      ctrl = @data[pos + base_pos].ord
      pos += 1

      type = ctrl >> 5
Severity: Major
Found in lib/maxminddb.rb - About 2 hrs to fix

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

        def lookup(ip_or_hostname)
          if @local_ip_alias && is_local?(ip_or_hostname)
            ip_or_hostname = @local_ip_alias
          end
    
    
    Severity: Minor
    Found in lib/maxminddb.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 decode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def decode(pos, base_pos)
          ctrl = @data[pos + base_pos].ord
          pos += 1
    
          type = ctrl >> 5
    Severity: Minor
    Found in lib/maxminddb.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 read_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_record(node_no, flag)
          rec_byte_size = @node_byte_size / 2
          pos = @node_byte_size * node_no
          middle = @data[pos + rec_byte_size].ord if @node_byte_size.odd?
          if flag == 0 # left
    Severity: Minor
    Found in lib/maxminddb.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

    Method addr_from_ip has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def addr_from_ip(ip_or_hostname)
          klass = ip_or_hostname.class
    
          return ip_or_hostname if RUBY_VERSION.to_f < 2.4 && (klass == Fixnum || klass == Bignum)
          return ip_or_hostname if RUBY_VERSION.to_f >= 2.4 && klass == Integer
    Severity: Minor
    Found in lib/maxminddb.rb - 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