-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Activate removeWildcardImports()
in Spotless
#4704
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
Conversation
4194375
to
7a65f20
Compare
When I run the build with that wildcard import, it fails:
In other words, this is already covered by Checkstyle.
In light of that, I am closing this PR. |
With regard to the aforementioned In any case, removing wildcard imports without replacing them with actual valid imports does not seem very helpful in my opinion. |
removeWildcardImports()
removeWildcardImports()
in Spotless
|
while having the same feat. spotless goes beyond annoying but fixing the issue. Actually there is no need to have checkstyle anymore if spot is configured, its ready to take over. |
Before submitting a PR (or before the core team pushes anything to GitHub), a full build with checks and tests is required.
As for whether |
right, sorry for that.
Yes in maven it would be a verify phase, gradle has something similar for sure. |
From what I can tell, the new Spotless feature does not "fix" anything. Rather, it simply removes all wildcard imports, which can result in the code no longer compiling. Thus, rather than "fixing" the code, I'd say it actually "breaks" the code. |
Yes in this case its actually true, wanted to mention this detail as well. But the this is the exception. Normally spot will replace with equivalent fix. We will work on the full replacement that IDEA offers. If IDEA is correctly configured, avoiding wildcards, this could be leveraged for skilled IDE users, as the non-compiling file will be open in an ease, and then imports are added automatically sometimes. Or just replace the diff in IDE and apply the wildcard replacement. Yes thats complicated as requires one extra step. While check just breaks, assuming it offers no navigation.
"Breaks" the build, assuming and hoping that you cannot deliver non-compiling code. So that's ment to be a feature, but it still imposes a small risk on a build, if its not checking for compiling. This will cause problems with this solution and should be reconsidered. For real security and stability, we should just fail the build on the spot and not change it, in my opinion. Just changing the goal from This is a very small risk, but a real one. |
That is the exact behavior we currently have with the Checkstyle check. See #4704 (comment).
The same is true for any IDE that one uses to work on JUnit code, and the core JUnit team developers rely on that, as I assume most developers do. |
activation of:
removeWildcardImports
step diffplug/spotless#2517Might be forbidden to use wildcard imports (e.g., import static org.junit.jupiter.api.Assertions.*;) in Java code.
But build seems not to care about. As my BUILD SUCCESSFUL.
I hereby agree to the terms of the JUnit Contributor License Agreement.
Definition of Done
@API
annotations