Class RangeSet
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class RangeSet
include Enumerable
attr_reader :ranges
Method rangify
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def rangify(list, compress = false)
last_item = nil
list.sort.inject([]) do |ret, item|
if last_item
- 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
File range_set.rb
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'set'
module TwitterCldr
module Utils
Method flatten
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def flatten
return if ranges.size <= 1
sorted_ranges = ranges.sort do |a, b|
if is_numeric_range?(a) && is_numeric_range?(b)
- 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 includes_range?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def includes_range?(range)
result = bsearch do |cur_range|
fo = front_overlap?(cur_range, range)
ro = rear_overlap?(cur_range, range)
- 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 intersection
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def intersection(range_set)
new_ranges = []
range_set.ranges.each do |their_range|
ranges.each do |our_range|
- 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 subtract
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def subtract(range_set)
return self if range_set.empty?
remaining = range_set.ranges.dup
current_ranges = ranges.dup
new_ranges = []
- 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 to_a
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_a(compress = false)
if compress
ranges.map do |range|
if range.first == range.last
range.first
- 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"