Description
Add Checkstyle checks for all rules under §3.3.1 - Wildcard Imports of the OpenJDK Java Style Guidelines v6.
https://checkstyle.org/styleguides/openjdk-java-style-v6/openjdk-styleguide.html#s3.3.1-wildcard-imports
Parent issue: #19604

Rules covered
Wildcard imports should in general not be used.
When importing a large number of closely-related classes (such as implementing a visitor over a tree with dozens of distinct “node” classes), a wildcard import may be used.
In any case, no more than one wildcard import per file should be used.
Motivation
Wildcard imports makes it unclear what actually needs to be imported.
Having more than one wildcard import makes the code fragile since adding a new class in one of the imported packages can introduce a name clash.
An unused import gives a false impression of a dependency. Also, many IDEs list such import statements as warnings which clutters the list of problems.
Checks to add to openjdk_checks.xml
TreeWalker-level:
<module name="AvoidStarImport"/>
Files to update in PR(s)
- openjdk_checks.xml
- openjdk_style.xml (replace the relevant ??? entry for §3.3.1)
- Integration tests under the OpenJDK style chapter/rule folder structure
Progress tracker
| Check |
Rule |
Status |
| AvoidStarImport |
No wildcard imports |
|
| AvoidStarImport |
No static wildcard imports |
|
Description
Add Checkstyle checks for all rules under §3.3.1 - Wildcard Imports of the OpenJDK Java Style Guidelines v6.
https://checkstyle.org/styleguides/openjdk-java-style-v6/openjdk-styleguide.html#s3.3.1-wildcard-imports
Parent issue: #19604

Rules covered
Wildcard imports should in general not be used.
When importing a large number of closely-related classes (such as implementing a visitor over a tree with dozens of distinct “node” classes), a wildcard import may be used.
In any case, no more than one wildcard import per file should be used.
Motivation
Wildcard imports makes it unclear what actually needs to be imported.
Having more than one wildcard import makes the code fragile since adding a new class in one of the imported packages can introduce a name clash.
An unused import gives a false impression of a dependency. Also, many IDEs list such import statements as warnings which clutters the list of problems.
Checks to add to openjdk_checks.xml
TreeWalker-level:
<module name="AvoidStarImport"/>Files to update in PR(s)
Progress tracker