Class ActiveRecordAdapter
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class ActiveRecordAdapter < AbstractAdapter
def self.version_greater_or_equal?(version)
Gem::Version.new(ActiveRecord.version).release >= Gem::Version.new(version)
end
Method merge_non_empty_conditions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def merge_non_empty_conditions(behavior, conditions_hash, sql)
conditions = sanitize_sql(conditions_hash)
case sql
when true_sql
behavior ? true_sql : "not (#{conditions})"
- 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 deep_merge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def deep_merge(base_hash, added_hash)
added_hash.each do |key, value|
if base_hash[key].is_a?(Hash)
deep_merge(base_hash[key], value) unless value.empty?
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 parent_child_conditions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def parent_child_conditions(parent, child, all_conditions)
child_class = child.is_a?(Class) ? child : child.class
parent_class = parent.is_a?(Class) ? parent : parent.class
foreign_key = child_class.reflect_on_all_associations(:belongs_to).find do |association|
- 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 child_association_to_parent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def child_association_to_parent(parent, child)
child_class = child.is_a?(Class) ? child : child.class
parent_class = parent.is_a?(Class) ? parent : parent.class
association = child_class.reflect_on_all_associations(:belongs_to).find do |belongs_to_assoc|
- 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"