[java] Enhance rule ReplaceEnumerationWithIterator to flag usages of Enumeration
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.5k
- Forks
- 1.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 54
Description
Is your feature request related to a problem? Please describe.
The rule ReplaceEnumerationWithIterator currently flags only implementations of Enumeration.
It should be extended to flag also usages of Enumeration so that the relatively newer interface Iterator is used instead.
Describe the solution you'd like
The rule should detect all occurrences of Enumeration. The description for the rule should suggest to
replace all instances of Enumeration with Iterator using the method Enumeration.asIterator introduced since Java 9.
package pmdtests;
import java.util.Collections;
import java.util.Enumeration;
public enum TestEnumeration {
;
public static void main(String... args) {
Enumeration<Integer> numeration = Collections.emptyEnumeration();
}
}
Describe alternatives you've considered
None.
Additional context
None.
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 ReplaceEnumerationWithIterator rule and its linked documentation. Review how the rule currently handles Enumeration implementations, then extend coverage to usages and update the rule description to mention replacing Enumeration with Iterator via Enumeration.asIterator. Verify that the supplied generic Enumeration example is flagged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100