Method ensure_taxonomies_not_escalated
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ensure_taxonomies_not_escalated
Taxonomy.types.each do |taxonomy|
assoc_base = taxonomy.to_s.downcase
assoc = assoc_base.pluralize
key = assoc_base + '_ids'
- 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 taxable_ids
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def taxable_ids(loc = which_location, org = which_organization, inner_method = which_ancestry_method)
# Return everything (represented by nil), including objects without
# taxonomies. This value should only be returned for admin users.
return nil if any_context?(loc) && any_context?(org) &&
User.current.try(:admin?)
- 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 set_current_taxonomy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_current_taxonomy
if new_record? && errors.empty?
# we need to use _ids methods so that DirtyAssociations is correctly saved
self.location_ids += [Location.current.id] if add_current_location?
self.organization_ids += [Organization.current.id] if add_current_organization?
- 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"