celluloid/celluloid-dns

View on GitHub
lib/celluloid/dns/extensions/resolv.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

            def self.create(arg)
                case arg
                when IPv6
                    return arg
                when String
Severity: Minor
Found in lib/celluloid/dns/extensions/resolv.rb - 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

Method create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def self.create(arg)
                case arg
                when IPv6
                    return arg
                when String
Severity: Minor
Found in lib/celluloid/dns/extensions/resolv.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                            if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
                                a1 = ''.b
                                a2 = ''.b
                                prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
                                suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
    Severity: Major
    Found in lib/celluloid/dns/extensions/resolv.rb - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status