app/services/checklist/timeline.rb
Method add_intervals
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Open
def add_intervals
(@timelines + [self]).flatten.each do |timeline|
timeline.timeline_events.each_with_index do |event, idx|
interval =
if idx < (timeline.timeline_events.size - 1)
- 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_intervals
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def add_intervals
(@timelines + [self]).flatten.each do |timeline|
timeline.timeline_events.each_with_index do |event, idx|
interval =
if idx < (timeline.timeline_events.size - 1)
Consider simplifying this complex logical expression. Open
Open
if (event.is_addition? || event.is_amendment? || event.is_deletion?) &&
@current || event.is_reservation? && event.is_current
@continues_in_present = true
Checklist::TimelineInterval.new(
:taxon_concept_id => @taxon_concept_id,
Consider simplifying this complex logical expression. Open
Open
if prev_event && (
prev_event.is_addition? ||
prev_event.change_type_name == 'AMENDMENT'
) &&
event.is_addition? &&
Method change_consecutive_additions_to_amendments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def change_consecutive_additions_to_amendments
(@timelines + [self]).flatten.each do |timeline|
prev_event = nil
timeline.timeline_events.each_with_index do |event, idx|
if prev_event && (
- 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"