Method move_to_child_with_index
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def move_to_child_with_index(node, index)
siblings = node == :root ? roots : node.children
if siblings.empty?
move_to_child_of(node)
elsif siblings.count == index
- 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 move_to_ordered_child_of
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def move_to_ordered_child_of(parent, order_attribute, ascending = true)
self.move_to_root and return unless parent
left_neighbor = find_left_neighbor(parent, order_attribute, ascending)
self.move_to_child_of(parent)
- 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_left_neighbor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_left_neighbor(parent, order_attribute, ascending)
left = nil
parent.children.each do |n|
if ascending
left = n if n.send(order_attribute) < self.send(order_attribute)
- 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"