Method merge_overlaps
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def merge_overlaps(merge_same_value = true)
return MultiRange.new([]) if @ranges.size == 0
new_ranges = []
current_range = nil
- Read upRead up
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
Class MultiRange
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class MultiRange
INDEX_WITH_DEFAULT = Object.new
attr_reader :ranges
Method -
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
def -(other)
return difference_with_other_multi_range(other) if other.is_a?(MultiRange)
new_ranges = @ranges.dup
return MultiRange.new(new_ranges) if not overlaps_with_range?(other)
- Read upRead up
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 possible_sub_ranges_of
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def possible_sub_ranges_of(range, other)
sub_range1 = range.begin...other.begin if other.begin
if other.end
sub_range2_begin = if other.exclude_end?
- Read upRead up
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 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(ranges)
if ranges.is_a? MultiRange
@ranges = ranges.ranges
@is_float = ranges.is_float?
else
- Read upRead up
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
Avoid too many return
statements within this method. Open
return range1.end + 1 >= range2.begin
Avoid too many return
statements within this method. Open
return range2
Avoid too many return
statements within this method. Open
return range1 if range1.exclude_end?