openrewrite / openrewrite/rewrite-static-analysis
RSPEC-2864 - entrySet()" should be iterated when both the key and value are needed
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 62
- Forks
- 112
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 40
Description
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
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the RSPEC-2864 page, then read SpotBugs' WrongMapIterator.java and the WMITest.java cases linked in the issue to understand the expected pattern. Identify the corresponding OpenRewrite recipe and test locations before implementing the rule; done means the referenced inefficient map iteration is detected and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100