SpeciesFileGroup/taxonworks

View on GitHub
app/models/role.rb

Summary

Maintainability
A
45 mins
Test Coverage

Method cached_trigger_methods has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def cached_trigger_methods(object)
    k = object.class.base_class.name.to_sym
    if cached_triggers[k]
      cached_triggers[k]
    elsif
Severity: Minor
Found in app/models/role.rb - About 45 mins to fix

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

  # TODO: redundant?
Severity: Minor
Found in app/models/role.rb by fixme

TODO found
Open

  # !! TODO: revist
Severity: Minor
Found in app/models/role.rb by fixme

TODO found
Open

# TODO: these are being used in Attribution, or not?
Severity: Minor
Found in app/models/role.rb by fixme

Prefer the new style validations validates :column, presence: value over validates_presence_of.
Open

  validates_presence_of :type
Severity: Minor
Found in app/models/role.rb by rubocop

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

There are no issues that match your filters.

Category
Status