Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a checkstyle lint banning wildcard imports #220

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

eigenraven
Copy link
Member

Shows an error for every non-static wildcard import in java files in the mod on build/check gradle tasks:

> Task :checkstyleMain FAILED
[ant:checkstyle] [ERROR] /home/raven/MC/modding/1710/ExampleMod1.7.10/src/main/java/com/myname/mymodid/CommonProxy.java:3:33: Using the '.*' form of import should be avoided - cpw.mods.fml.common.event.*. [AvoidStarImport]
[ant:checkstyle] [ERROR] /home/raven/MC/modding/1710/ExampleMod1.7.10/src/main/java/com/myname/mymodid/Config.java:3:15: Using the '.*' form of import should be avoided - java.io.*. [AvoidStarImport]
[ant:checkstyle] [ERROR] /home/raven/MC/modding/1710/ExampleMod1.7.10/src/main/java/com/myname/mymodid/MyMod.java:3:32: Using the '.*' form of import should be avoided - org.apache.logging.log4j.*. [AvoidStarImport]
[ant:checkstyle] [ERROR] /home/raven/MC/modding/1710/ExampleMod1.7.10/src/main/java/com/myname/mymodid/MyMod.java:5:27: Using the '.*' form of import should be avoided - cpw.mods.fml.common.*. [AvoidStarImport]
[ant:checkstyle] [ERROR] /home/raven/MC/modding/1710/ExampleMod1.7.10/src/main/java/com/myname/mymodid/MyMod.java:6:33: Using the '.*' form of import should be avoided - cpw.mods.fml.common.event.*. [AvoidStarImport]

Can be suppressed by doing:

// CHECKSTYLE:OFF
import my.mod.magic.*;
// CHECKSTYLE:ON

or globally in gradle.properties.

@eigenraven eigenraven requested review from a team September 22, 2023 18:56
@eigenraven eigenraven self-assigned this Sep 22, 2023
Copy link
Member

@BlueWeabo BlueWeabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are a wizard. Thank you very much. Allows me to not need to bother with GHA to do it on that side :P

@eigenraven eigenraven merged commit 74a5889 into master Sep 22, 2023
1 check passed
@eigenraven eigenraven deleted the check-wildcard-imports branch September 22, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants