1

So I been messing around and created a library with my favorite methods that I use several projects. But those annoying unused method and method can be private (because it's intended to be used publicly but also used in the library somewhere else) warnings keep appearing and I want to keep the library clean.

Is there a way to tell the compiler that a class or file is intended to be used as a library?

Currently am using @Suppress("unused", "MemberVisibilityCanBePrivate") but this just feels wrong.

Then Enok
  • 593
  • 5
  • 16
  • I guess adding an interface for each class might also work... But again, feels wrong. – Then Enok Nov 03 '19 at 09:51
  • 1
    Does this answer your question? [Disable "not used" warning for public methods of a class](https://stackoverflow.com/questions/6166334/disable-not-used-warning-for-public-methods-of-a-class) – IlyaMuravjov Nov 03 '19 at 10:20
  • Thanks @Bananon, but I do want those warnings for non library files – Then Enok Nov 03 '19 at 22:45

1 Answers1

4

Those "annoying" unused method and method can be private warnings, actually are saying that you are neven calling those methods, and that's right when it comes to be an library, but it is wrong if we consider that all single public methdo must have a unit test for it. If you had a single junit testing such methods the compiler/checker would not bother you with that ;)

Solution: create junit for those library methods and will get ride of those messages and at same time you will get a safer code!