modules/reporting/lib/report/query_utils.rb
Method compare
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def compare(first, second)
first = Array(first).flatten
second = Array(second).flatten
first.zip second do |a, b|
return (a <=> b) || (a == Infinity ? 1 : -1) if a != 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"
Further reading
Method field_name_for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
Wontfix
def field_name_for(arg)
return "NULL" unless arg
return field_name_for(arg.keys.first) if arg.is_a? Hash
return "#{table_name_for(arg.first)}.#{arg.last}" if arg.is_a? Array and arg.size == 2
- 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"