You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Sounds good. Spotless is optimized for code formatting of the form String -> String. If you want to disallow wildcards, you can fudge it with Spotless, or use another tool. I don't think it makes sense to integrate static code analysis with Spotless unless it produces the String -> String output required for spotlessApply to work.
Activity
diffplug/spotless#240 : Example for issue.
scottresnik commentedon Apr 28, 2018
Example on github.
nedtwigg commentedon Apr 28, 2018
Consider this situation:
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.
[-]Wild card imports are ignored[/-][+]Unused wild card imports are not removed[/+]scottresnik commentedon Apr 28, 2018
I kind of figured that would be the case.
What do you think about a setting to fail on cases of wild card imports?
nedtwigg commentedon Apr 28, 2018
You can use a custom rule, something like:
scottresnik commentedon Apr 30, 2018
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.
nedtwigg commentedon Apr 30, 2018
Sounds good. Spotless is optimized for code formatting of the form
String -> String
. If you want to disallow wildcards, you can fudge it with Spotless, or use another tool. I don't think it makes sense to integrate static code analysis with Spotless unless it produces theString -> String
output required forspotlessApply
to work.