Method update_column_from_params
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_column_from_params(parent_record, column, attribute, avoid_changes = false)
value = column_value_from_param_value(parent_record, column, attribute, avoid_changes)
if column.association
if avoid_changes
parent_record.association(column.name).target = value
- 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 attributes_hash_is_empty?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def attributes_hash_is_empty?(hash, klass)
hash.all? do |key, value|
# convert any possible multi-parameter attributes like 'created_at(5i)' to simply 'created_at'
column_name = key.to_s.split('(', 2)[0]
- 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 update_record_from_params
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_record_from_params(parent_record, columns, attributes, avoid_changes = false)
crud_type = parent_record.new_record? ? :create : :update
return parent_record unless parent_record.authorized_for?(:crud_type => crud_type)
multi_parameter_attrs = multi_parameter_attributes(attributes)
- 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 update_column_association
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_column_association(parent_record, column, attribute, value)
if belongs_to_counter_cache_hack?(column.association, attribute)
parent_record.send "#{column.association.foreign_key}=", value&.id
parent_record.association(column.name).target = value
elsif column.association.collection? && column.association.through_singular?
- 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 find_or_create_for_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_or_create_for_params(params, parent_column, parent_record)
current = parent_record.send(parent_column.name)
klass = parent_column.association.klass(parent_record)
if params.key? klass.primary_key
record_from_current_or_find(klass, params[klass.primary_key], current)
- 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"