12

The list of the most common SuppressWarnings annotations is so long and non-intuitive, that I am lost to find a correct annotation for warning

Boolean method 'methodName' is always inverted

I don't want to change the method to return a negative value, since there is a logic consistency in the naming - e.g. method name is: hasFlag(...).

What is the right annotation for this type of Lint Analysis warning?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ωmega
  • 42,614
  • 34
  • 134
  • 203

1 Answers1

27
@SuppressWarnings("BooleanMethodIsAlwaysInverted")

You can discover these with the help of Android Studio. Expand the quick fix menu (alt+enter on my computer) and then choose one of the suppress quick fixes.

laalto
  • 150,114
  • 66
  • 286
  • 303
  • Exactly what I needed. **Thank you!** Yes, I am using `Alt+Enter`, but for some unknown reason this time Android Studio came with no suppress suggestion. – Ωmega Oct 04 '18 at 15:55
  • 1
    Suppress quick fixes seem to be now under the "fix" item (often the topmost), one menu level down. On some earlier version of Studio they were on the top level. – laalto Oct 04 '18 at 19:09
  • 2
    This was no where in the list of quick fixes. This was no where in the entire list of lint warnings, which I searched through. I don't know what the deal is, but Android Studio should have that information more easily available. – Peter Griffin Nov 12 '18 at 22:57