unepwcmc/SAPI

View on GitHub
app/services/checklist/timeline.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method add_intervals has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
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)
Severity: Minor
Found in app/services/checklist/timeline.rb - About 2 hrs 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

Method add_intervals has 31 lines of code (exceeds 25 allowed). Consider refactoring.
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)
Severity: Minor
Found in app/services/checklist/timeline.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    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,
    Severity: Major
    Found in app/services/checklist/timeline.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if prev_event && (
                prev_event.is_addition? ||
                  prev_event.change_type_name == 'AMENDMENT'
                ) &&
                event.is_addition? &&
      Severity: Major
      Found in app/services/checklist/timeline.rb - About 40 mins to fix

        Method change_consecutive_additions_to_amendments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        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 && (
        Severity: Minor
        Found in app/services/checklist/timeline.rb - About 35 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

        There are no issues that match your filters.

        Category
        Status