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

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" }



Hi Mark,

Try to alt+Enter on an unwanted warning and choose 'Supress for class'

Screen Shot 2012-12-18 at 1.40.56 .png
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"

Screen Shot 2012-12-19 at 4.27.04 PM.png


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




You can actually suppress any inspection. So it is useful to know how to do it in general case.