RSPEC-2864 - entrySet()" should be iterated when both the key and value are needed
Describe the situation before applying the recipe
See https://rules.sonarsource.com/java/RSPEC-2864/
Describe the situation after applying the recipe
Have you considered any alternatives or workarounds?
Any additional context
This is a SpotBugs error https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html#wmi-inefficient-use-of-keyset-iterator-instead-of-entryset-iterator-wmi-wrong-map-iterator
https://github.com/spotbugs/spotbugs/blob/d999c35c134f5310b688f2b4513e3689fb1439bc/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/WrongMapIterator.java#L256
Test cases here https://github.com/spotbugs/spotbugs/blob/d999c35c134f5310b688f2b4513e3689fb1439bc/spotbugsTestCases/src/java/WMITest.java#L10
Are you interested in contributing this recipe to OpenRewrite?
Thanks for the helpful example links; indeed would be a neat addition to see this fixed with a recipe.
This issue is stale because it has not had any activity for 60 days. Remove question label or comment or this will be closed in two weeks. Issues may be reopened when there is renewed interest.