Class Tag
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Tag < ActiveRecord::Base
validates_presence_of :name, on: :create, message: "can't be blank"
validates_presence_of :user_id, on: :create, message: "can't be blank"
validates_presence_of :spectrum_id, on: :create, message: "can't be blank"
Method change_reference
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def change_reference(snapshot_id)
# only free, un-depended-on tags can do this
if snapshot.has_no_dependent_spectra? && !snapshot.has_subsequent_depended_on_snapshots?
old_name = name
old_name = old_name.split('#')[0] if has_reference?
- 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 is_deletable?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def is_deletable?
if is_powertag? && needs_snapshot?
if snapshot.nil?
true
elsif snapshot.is_deletable? # includes snapshot.is_latest?
- 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 add_reference
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_reference(snapshot_id)
unless has_reference?
spectrum = Spectrum.find(value)
if spectrum.snapshots && !spectrum.snapshots.empty?
snapshot_id ||= spectrum.snapshots.last.id
- 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"