-
Notifications
You must be signed in to change notification settings - Fork 458
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
Unused wild card imports are not removed #240
Comments
Consider this situation: import pkgA.*;
import pkgB.*;
public class Clazz {
WhatPackageDidIComeFrom field;
} Without slurping in the classpath, and then looking at the classfiles in those jars, we cannot know which package it came from. Basically requires a full compile. With #239 it might be vaguely possible to do, but it will certainly be a lot of work. |
I kind of figured that would be the case. What do you think about a setting to fail on cases of wild card imports? |
You can use a custom rule, something like: custom 'noWildcardImports', {
if (it.contains('*;\n')) {
throw new Error('No wildcard imports allowed')
}
}
bumpThisNumberIfACustomStepChanges(1) |
Thanks @nedtwigg . While that would work, I think the a cleaner solution would be to use one of the static code analysis tools out there. |
Sounds good. Spotless is optimized for code formatting of the form |
Wild card imports seem to be ignored if they are unused. Is it possible to correct this? At the very least would it be possible to add a setting to fail if wild card imports are encountered?
The text was updated successfully, but these errors were encountered: