dougfales/gpx

View on GitHub
lib/gpx/segment.rb

Summary

Maintainability
C
1 day
Test Coverage

Method append_point has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def append_point(pt)
      last_pt = @points[-1]
      if pt.time
        @earliest_point = pt if @earliest_point.nil? || (@earliest_point.time && pt.time < @earliest_point.time)
        @latest_point = pt if @latest_point.nil? || (@latest_point.time && pt.time > @latest_point.time)
Severity: Minor
Found in lib/gpx/segment.rb - About 3 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 update_meta_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update_meta_data(pt, last_pt)
      if pt.time
        @earliest_point = pt if @earliest_point.nil? || (pt.time < @earliest_point.time)
        @latest_point = pt if @latest_point.nil? || (pt.time > @latest_point.time)
      else
Severity: Minor
Found in lib/gpx/segment.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 find_closest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def find_closest(pts, time)
      return pts.first if pts.size == 1

      midpoint = pts.size / 2
      if pts.size == 2
Severity: Minor
Found in lib/gpx/segment.rb - About 1 hr 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 smooth_location_by_average has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def smooth_location_by_average(opts = {})
      seconds_either_side = opts[:averaging_window] || 20

      # calculate the first and last points to which the smoothing should be applied
      earliest = (find_point_by_time_or_offset(opts[:start]) || @earliest_point).time
Severity: Minor
Found in lib/gpx/segment.rb - About 1 hr to fix

    There are no issues that match your filters.

    Category
    Status