Method extracted_searchable_proximity_hash
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def extracted_searchable_proximity_hash(query_params, ip)
return false unless query_params[:stolenness] == "proximity"
location = query_params[:location]
return false unless location && !(location =~ /anywhere/i)
distance = query_params[:distance]&.to_i
- 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 searchable_query_items_colors
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def searchable_query_items_colors(query_params)
# params[:colors] should be an array (or a comma delineated string) - otherwise we parse out of the query string
if query_params[:colors].present?
colors = query_params[:colors].is_a?(String) ? query_params[:colors].split(",") : query_params[:colors]
return {colors: colors.map { |id| Color.friendly_find_id(id) }.compact}
- 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 searchable_query_items_manufacturer
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def searchable_query_items_manufacturer(query_params)
# we expect a singular manufacturer but deal with arrays because the multi-select search
manufacturer_id = extracted_query_items_manufacturer_id(query_params)
if manufacturer_id && !manufacturer_id.is_a?(Integer)
manufacturer_id = [manufacturer_id].flatten.map { |m_id|
- 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"