In a library project, I see numerous warnings suggesting that I reduce the visibility of public classes and methods. (Or in the case of methods I haven't written tests for, warnings about them being unused.) I'm using IntelliJ IDEA, but I assume that similar warnings would be seen if my project were imported into another IDE.
Should I use @SuppressWarnings("WeakerAccess")
on all my intended entry points, or is there a more succinct IDE-agnostic way of expressing this?
Obviously, the fact that the classes and methods are public
is supposed to convey that they're intended entry points. You could argue that the inspection just moves the possibility for error from the access modifier to the annotation. But thanks to the unfortunate defaults in most IDEs (which I've changed, BTW), mistakenly making something public
is often an error of omission, whereas a mistaken annotation at least requires an error of commission. So I think the inspection is useful in that regard. I'm just not sure of the best way to suppress false positives.