Groovy @SuppressWarnings("unused") goes unused
I keep trying to put @SuppressWarnings("unused") on a few class variables in my Groovy class that are unused. But it doesn't remove the warning from IntelliJ. Not sure if I have a typo or something wrong on my end.
Some short examples where it doesn't work
@SuppressWarnings("unused")
def createPot ={ handDocument ->
@SuppressWarnings("unused") public interface MongoDBRepository {
@SuppressWarnings("unused") public static final String JOURNAL_SAFE = "JOURNAL_SAFE" public static final String SAFE = "SAFE" public static final String MAJORITY = "MAJORITY" public static final String NORMAL = "NORMAL" }
Thanks
Mark
Please sign in to leave a comment.
Hi Mark,
Try to alt+Enter on an unwanted warning and choose 'Supress for class'
The same way you can suppress all other warnings.
Nope, sorry that option will not show up in Groovy file.
I had tried that first before I had even put the annotation in manually.
When you hit alt-enter (Mac here btw, and alt-enter is used to do imports) Anyway, in this context if you hit alt-enter the popup menu options are only
"safe delete",
"convert to closure property"
"make private"
"make public"
"make protected"
Mark
Ah, sorry. I didn't mention that you need to press right arrow on 'safe delete' item. Actually all items here have a submenu. Youu can notice it by grey triangles on right side of each item.
Thanks. And after doing that I find that it isn't "unused" that I need to use in this case when it is a groovy method/closure.
But I should be using
@SuppressWarnings("GroovyUnusedDeclaration")
Mark
You can actually suppress any inspection. So it is useful to know how to do it in general case.