Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What value for @SuppressWarnings do I use to suppress the "Can be private" warning?

I keep getting annoyed by the "Can be private" warning, however my FirebaseRecyclerAdapter will not work in that case. So, is there a @SuppressWarnings for that?

What I've tried:

@SuppressWarnings("all") but that's not what I want.

Note: I am using Android Studio

like image 823
Ali Bdeir Avatar asked Jul 28 '16 06:07

Ali Bdeir


People also ask

How do you supress a warning?

Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.

What is suppress warning unused?

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" ).

What is @SuppressWarnings null?

null to suppress warnings relative to null analysis. restriction to suppress warnings relative to usage of discouraged or forbidden references. serial to suppress warnings relative to missing serialVersionUID field for a serializable class. static-access to suppress warnings relative to incorrect static access.


1 Answers

It is best to simply disable this inspection, either for your whole project or for a specific class. Put your cursor on the warning and press Alt + Enter to bring up the following menu, which allows you to disable it:

Disable inspection

If you really want to use @SuppressWarnings you can choose the Suppress for class option from the dialog above. This will add the following annotation:

@SuppressWarnings("WeakerAccess") 
like image 139
Aerus Avatar answered Sep 27 '22 17:09

Aerus