Class BelongsToAssociation
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class BelongsToAssociation < SingularAssociation # :nodoc:
def handle_dependency
return unless load_target
case options[:dependent]
Method replace_keys
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def replace_keys(record, force: false)
reflection_fk = reflection.foreign_key
if reflection_fk.is_a?(Array)
target_key_values = record ? Array(primary_key(record.class)).map { |key| record._read_attribute(key) } : []
- 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 handle_dependency
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_dependency
return unless load_target
case options[:dependent]
when :destroy
- 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 decrement_counters_before_last_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def decrement_counters_before_last_save
if reflection.polymorphic?
model_type_was = owner.attribute_before_last_save(reflection.foreign_type)
model_was = owner.class.polymorphic_class_for(model_type_was) if model_type_was
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"