Method indentation_delta
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def indentation_delta(tokens)
# We need to keep track of whether we've seen a "for" on this line because
# if the line ends with "do" then that "do" should be discounted (i.e. we're
# only opening one level not two) To do this robustly we want to keep track
# of the indent level at which we saw the for, so we can differentiate
- 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 indentation_delta
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def indentation_delta(tokens)
# We need to keep track of whether we've seen a "for" on this line because
# if the line ends with "do" then that "do" should be discounted (i.e. we're
# only opening one level not two) To do this robustly we want to keep track
# of the indent level at which we saw the for, so we can differentiate
Method track_module_nesting
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def track_module_nesting(token, kind)
if kind == :keyword && %w[class module].include?(token)
@module_nesting << [token, nil]
@awaiting_class = true
elsif @awaiting_class
- 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 indent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def indent(input)
output = ''
prefix = indent_level
input.lines.each do |line|
- 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"