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?
The Invert Boolean refactoring lets you change the sense of a Boolean method or variable to the opposite one.
@SuppressWarnings instruct the compiler to ignore or suppress, specified compiler warning in annotated element and all program elements inside that element. For example, if a class is annotated to suppress a particular warning, then a warning generated in a method inside that class will also be separated.
The @SuppressWarnings annotation disables certain compiler warnings. In this case, the warning about deprecated code ( "deprecation" ) and unused local variables or unused private methods ( "unused" ).
@SuppressWarnings("unchecked") is used when Java generics just don't let you do what you want to, and thus, you need to explicitly specify to the compiler that whatever you are doing is legal and can be executed at the time of execution.
@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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With