Method node_of_component
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def node_of_component(component)
case component
when Parsing::Number
AST::Number.new(component.value)
when Parsing::String
Method consume_operators_with_priority!
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def consume_operators_with_priority!(priority)
p_indexes = @priorities.map.with_index.select {|p,index| p == priority}
# :left, :right, or :none
associativity = AST::Operator.associativity_of_priority(priority)
- 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 consume_operators_with_priority!
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def consume_operators_with_priority!(priority)
p_indexes = @priorities.map.with_index.select {|p,index| p == priority}
# :left, :right, or :none
associativity = AST::Operator.associativity_of_priority(priority)
Method components_to_basic_nodes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def components_to_basic_nodes(components)
nodes_components = []
components.each do |component|
if component.is_a?(Keisan::Parsing::LineSeparator)
- 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 consume_operators!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def consume_operators!
loop do
break if @priorities.empty?
max_priority = @priorities.max
break if max_priority < 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"