File sorted_set.rb
has 742 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "hamster/immutable"
require "hamster/enumerable"
module Hamster
Class SortedSet
has 53 methods (exceeds 20 allowed). Consider refactoring. Open
class SortedSet
include Immutable
include Enumerable
class << self
Class AVLNode
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class AVLNode
def self.from_items(items, comparator, from = 0, to = items.size-1) # items must be sorted
size = to - from + 1
if size >= 3
middle = (to + from) / 2
Class Empty
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Empty
def initialize(comparator); @comparator = comparator; end
def natural_order?; false; end
def left; self; end
def right; self; end
Method slice
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def slice(arg, length = (missing_length = true))
if missing_length
if arg.is_a?(Range)
from, to = arg.begin, arg.end
from += @node.size if from < 0
- 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 eql?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def eql?(other)
return true if other.equal?(self)
return false if not instance_of?(other.class)
return false if size != other.size
a, b = self.to_enum, other.to_enum
- 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 delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def delete(item)
dir = direction(item)
if dir == 0
if @right.empty?
return @left # replace this node with its only child
- 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 find_index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_index(obj = (missing_obj = true), &block)
if !missing_obj
# Enumerable provides a default implementation, but this is more efficient
node = @node
index = node.left.size
- 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 disjoint?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def disjoint?(other)
if size < other.size
each { |item| return false if other.include?(item) }
else
other.each { |item| return false if include?(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
Method subsequence
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def subsequence(from, length)
return nil if from > @node.size || from < 0 || length < 0
length = @node.size - from if @node.size < from + length
if length == 0
if @node.natural_order?
- 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 bulk_delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bulk_delete(items)
return self if items.empty?
if items.size == 1
catch :not_present do
return delete(items.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"
Further reading
Method initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize(items=[], &block)
items = items.to_a
if block
if block.arity == 1 || block.arity == -1
comparator = lambda { |a,b| block.call(a) <=> block.call(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"