Method parse_address
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_address(a)
addr,subnet = a.split("/",2)
unless addr.kind_of?(String) && (addr =~ /^[0-9a-f:]+$/) &&
(! addr.include?(":::")) && addr.length >= 2
raise ArgumentError.new("#{addr} is not a valid IP6 address")
- Read upRead up
- Create a ticketCreate a ticket
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
File ip.rb
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
class IP
include Comparable
protected
# Translate a CIDR subnet specification into a bitfield
- Create a ticketCreate a ticket
Method canonical_address
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def canonical_address
f = 0
in_run = false
runs = Array.new
a = self.to_a
- Read upRead up
- Create a ticketCreate a ticket
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 initialize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def initialize(*a)
if a[0].kind_of?(String)
self.address = a[0]
elsif a[0].kind_of?(Integer)
unless self.class::RANGE.include?(a[0].abs)
- Read upRead up
- Create a ticketCreate a ticket
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_address
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.parse_address(a)
addr,subnet = a.split("/",2)
if addr.kind_of?(String) && (addr =~ MATCH_RE)
addr = addr.split(".").map do |i|
i = i.to_i
- Read upRead up
- Create a ticketCreate a ticket
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_address
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse_address(a)
addr,subnet = a.split("/",2)
unless addr.kind_of?(String) && (addr =~ /^[0-9a-f:]+$/) &&
(! addr.include?(":::")) && addr.length >= 2
raise ArgumentError.new("#{addr} is not a valid IP6 address")
- Create a ticketCreate a ticket
Method address=
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def address=(address)
if address.kind_of?(String)
@address,s = self.class.parse_address(address)
if s
@subnet = s.to_i
- Read upRead up
- Create a ticketCreate a ticket
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"