GeezerVison is showing github.com — Support removing wildcard imports via `removeWildcardImports` step by iddeepak · Pull Request #2517 · diffplug/spotless
Conversation
iddeepak
commented
Jun 18, 2025
•
edited by Goooler
Loading
Uh oh!
There was an error while loading. Please reload this page.
I have just opened a PR to help us say “goodbye” to those sneaky wildcard imports (like import java.util.*;) whenever Spotless tidies up our Java files. Wildcard imports can make it hard to see exactly which classes you’re relying on, so this change introduces a new step in the Spotless plugin that:
Spots any import foo.*; lines in your source
Removes them outright (so your IDE or build tools can regenerate only the exact imports you need)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tsaglam reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…WildcardsUnformatted.test
Co-authored-by: Consequences of Lacking Discipline <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Would you mind adding a test for the Gradle plugin?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pankraz76
commented
Jun 23, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
could migrate the .editorconfig as well dedicated, assuming spot it applied on itself, like checkstyle does impose all checks on itself, too.
|
ij_java_class_count_to_use_import_on_demand = 999 |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…s into remove-wildcard-imports
iddeepak
commented
Jun 23, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
could migrate the .editorconfig as well dedicated, assuming spot it applied on itself, like checkstyle does impose all checks on itself, too.
|
ij_java_class_count_to_use_import_on_demand = 999 |
you mean spot checks on .editorconfig something like this
format("editorconfig") { target "spotless/.editorconfig" editorConfig() }
@Pankraz76
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
No, sorry—I meant we could remove this config, assuming it's not needed anymore, as Spot will prevent it now. But keeping it wouldn't hurt, as it still helps to avoid potential issues.
If auto-fix were possible, the config would still help prevent problems before fixing them, in the first place, but it wouldn't be strictly necessary anymore.
The next version will go further and deliver actual imports to fully automate this.
A win for the project. Thanks for the good craftsmanship!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
No, sorry—I meant we could remove this config, assuming it's not needed anymore, as Spot will prevent it now. But keeping it wouldn't hurt, as it still helps to avoid potential issues.
If auto-fix were possible, the config would still help prevent problems before fixing them, in the first place, but it wouldn't be strictly necessary anymore.
The next version will go further and deliver actual imports to fully automate this.
A win for the project. Thanks for the good craftsmanship!
Ohh no my bad, I misunderstood it. Now it makes sense. Lets keep that setting in place as an extra safety as of now. Without it, IntelliJ’s default of 5 would collapse to a wildcard on the 6th import, then Spotless would strip that wildcard and force everyone to re-import.
|
jhult reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I meant we could remove this config, assuming it's not needed anymore, as Spot will prevent it now.
It could be honored by the IDEA side.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Goooler
changed the title
Remove wildcard imports
Add support for removing wildcard imports via removeWildcardImports step
Jun 24, 2025
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Goooler
changed the title
Add support for removing wildcard imports via removeWildcardImports step
Support removing wildcard imports via removeWildcardImports step
Jun 24, 2025
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea on removeObsoletes().
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
importOrderFile('eclipse-import-order.txt') // import order file as exported from eclipse
|
|
|
|
|
|
removeUnusedImports()
|
|
|
removeWildcardImports()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removeObsoletes()
removeObsoleteInit()
removeObsoleteInitializations()
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jun 24, 2025
|
Released in plugin-gradle 7.1.0 and plugin-maven 2.45.0.
|
marcusdacoregio, iddeepak, james-hayes-emburse, Pankraz76, and awa-xima reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 16, 2025
Reviewers
+2 more reviewers
Goooler
Goooler approved these changes
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|