komoot / photon

an open source geocoder for openstreetmap data
Apache License 2.0
1.83k stars 278 forks source link

Removed 4 unnecessary stubbings in ReverseRequestFactory.java  #754

Closed ARUS2023 closed 8 months ago

ARUS2023 commented 8 months ago

In our analysis of the project, we observed that 1) 3 stubbings which stubbed queryParamOrDefault, queryMap("osm_tag”), queryMap("layer") are created in ReverseRequestFactoryt.createRequestWithLongitudeLatitude method but never executed in 7 tests: ReverseRequestFactory.testWithHighLongitude, ReverseRequestFactory.testWithLowLongitude, ReverseRequestFactory.testWithHighLatitude, ReverseRequestFactory.testWithLowLatitude, ReverseRequestFactory.testWithNegativeRadius, ReverseRequestFactory.testWithZeroRadius, ReverseRequestFactory.testWithBadRadius.

2) 2 stubbings which stubbed queryMap("osm_tag"), and queryMap("layer") are created in ReverseRequestFactoryt.createRequestWithLongitudeLatitude method but never executed in 4 tests: ReverseRequestFactory.testWithBadLayerFilters, ReverseRequestFactory.testWithNegativeLimit, ReverseRequestFactory.testWithZeroLimit, ReverseRequestFactory.testWithBadLimit.

3) 1 stubbing which stubbed queryMap("osm_tag") is created in ReverseRequestFactoryt.createRequestWithLongitudeLatitude method but never executed in 2 tests: ReverseRequestFactory.testTagFilters, ReverseRequestFactory.testBadTagFilters.

4) 1 stubbing which stubbed queryMap("layer") is created in ReverseRequestFactoryt.createRequestWithLongitudeLatitude method but never executed in 2 tests: ReverseRequestFactory.testWithLayersFilters, ReverseRequestFactory.testWithDuplicatedLayerFilters,

5) 1 stubbing is created in requestWithOsmFilters but never executed.

Unnecessary stubbings are stubbed method calls that were never realized during test execution. Mockito recommends to remove unnecessary stubbings (https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/exceptions/misusing/UnnecessaryStubbingException.html).

We propose below a solution to remove the unnecessary stubbings.

lonvia commented 8 months ago

This looks like spamming from an automated tool. Please don't do that. Closing.