Method add
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def add(klass, formatter = nil, *args, &block)
formatter ||= block
if formatter.nil?
remove(klass)
else
- 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 add
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add(klass, formatter = nil, *args, &block)
formatter ||= block
if formatter.nil?
remove(klass)
else
Method formatter_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Wontfix
def formatter_for(klass) # :nodoc:
check_modules = true
until klass.nil?
formatter = @class_formatters[klass.name]
return formatter if formatter
- 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 remove
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove(klass)
Array(klass).each do |k|
if k.instance_of?(Module)
@module_formatters.delete(k)
else
- 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"