Refactor: extract resolvePostcode method and introduce explaining variables in Address#1777
Conversation
PR Summary
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1777 +/- ##
============================================
+ Coverage 92.37% 92.44% +0.06%
- Complexity 3448 3451 +3
============================================
Files 339 339
Lines 6794 6801 +7
Branches 670 670
============================================
+ Hits 6276 6287 +11
+ Misses 353 351 -2
+ Partials 165 163 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Refactors Address provider methods to reduce duplication and improve readability without changing behavior.
Changes:
- Extracted shared postcode generation logic into a private
resolvePostcode()helper used byzipCode(),postcode(), andeircode(). - Replaced numeric literals in
latitude()andlongitude()with explaining local variables.
| return String.format(faker.getContext().getLocale(), "%.8f", | ||
| (faker.random().nextDouble() * latitudeRange) - latitudeOffset); |
| return String.format(faker.getContext().getLocale(), "%.8f", | ||
| (faker.random().nextDouble() * longitudeRange) - longitudeOffset); |
|
AI PR |
Summary
Two small refactoring improvements in Address.java:
Reason for Refactoring:
Changes Made:
Address.java - Extract Method
Extracted duplicated postcode resolution logic from zipCode(), postcode(), and eircode() into a shared private method resolvePostcode().
Address.java - Introduce Explaining Variables
Replaced magic numbers in latitude() and longitude() with clearly named variables. These variables clarify the meaning of the numeric values used in the geographic calculations.
Testing:
Notes:
This PR contains only structural refactoring improvements to improve readability and maintainability without altering application behavior.