Class Criteria
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Criteria
extend Forwardable
include Enumerable
MULTI_VALUE_METHODS = [ :where, :or, :not, :order ]
Method ordering_args
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def ordering_args
Proc.new do |item|
order_values.map do |sort|
next unless [ :asc, :desc ].include?(sort.last)
sort.last == :desc ? -item.send(sort.first) : item.send(sort.first)
- 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 keep?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def keep?(record)
keep = where? ? criteria_matches?(record, where_values) : true
alt = or? ? criteria_matches?(record, or_values) : false
exclude = not? ? criteria_matches?(record, not_values) : false
(keep || alt) && !exclude
- 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 order
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def order(*args)
sort = {}
args.collect do |arg|
sort.merge!(arg.is_a?(Hash) ? arg : { arg => :asc })
end
- 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"