opentripplanner / OpenTripPlanner

An open source multi-modal trip planner
http://www.opentripplanner.org
Other
2.12k stars 1.01k forks source link

Refactor NearbyStopsFinder to follow strategy pattern #5906

Closed habrahamsson-skanetrafiken closed 2 weeks ago

habrahamsson-skanetrafiken commented 3 weeks ago

Summary

This PR is a pure refactor and shouldn't change any behaviour.

The NearbyStopsFinder has three different behaviours depending on two different parameters:

The different branches makes the code difficult to understand and difficult to test. This PR refactors this code to use the strategy pattern by extracting a common interface and having one class for each behaviour.

This work is in preparation of some work I need to do on access/egress search as part of #5848.

Unit tests

Unfortunately there is no tests for this piece of code. I would like to add some in a follow-up PR.

Documentation

I added and updated javadoc.

Bumping the serialization version id

Nope

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 92.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69.45%. Comparing base (b9e54d2) to head (960480d). Report is 25 commits behind head on dev-2.x.

Files Patch % Lines
.../graph_builder/module/DirectTransferGenerator.java 81.81% 1 Missing and 1 partial :warning:
...earbystops/PatternConsideringNearbyStopFinder.java 92.59% 0 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev-2.x #5906 +/- ## ============================================= - Coverage 69.45% 69.45% -0.01% - Complexity 17064 17072 +8 ============================================= Files 1927 1931 +4 Lines 73578 73587 +9 Branches 7549 7550 +1 ============================================= + Hits 51106 51109 +3 - Misses 19847 19853 +6 Partials 2625 2625 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.