app/models/role.rb
Method cached_trigger_methods
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def cached_trigger_methods(object)
k = object.class.base_class.name.to_sym
if cached_triggers[k]
cached_triggers[k]
elsif
- 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
TODO found Open
Open
# TODO: redundant?
- Exclude checks
TODO found Open
Open
# !! TODO: revist
- Exclude checks
TODO found Open
Open
# TODO: these are being used in Attribution, or not?
- Exclude checks
Prefer the new style validations validates :column, presence: value
over validates_presence_of
. Open
Open
validates_presence_of :type
- Read upRead up
- Exclude checks
This cop checks for the use of old-style attribute validation macros.
Example:
# bad
validates_acceptance_of :foo
validates_confirmation_of :foo
validates_exclusion_of :foo
validates_format_of :foo
validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo
# good
validates :foo, acceptance: true
validates :foo, confirmation: true
validates :foo, exclusion: true
validates :foo, format: true
validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true