I see that kotlin compiler doesn't issue a warning...
# announcements
d
I see that kotlin compiler doesn't issue a warning for unused functions/classes - only unused variables. I know this because I've enabled
-Werror
and then found a few of those unused in a codebase, no errors. Only IDE gives a warning on unused functions/classes. Can I somehow ask compiler to do this too?
b
I believe you can add cmd options in File -> settings -> build -> compiler (exact steps depends on IDE, but it definitely support search in it)
d
I'd like to do this with gradle then, so that this can be launched in the CI setting
But I see no options looking like what I want here: https://kotlinlang.org/docs/reference/compiler-reference.html
a
There is no such warning, and probably never will be. The general idea is to issue compiler warnings for code that definitely has a problem. All other cases should be covered by IDE inspections. For an unused variable, the compiler understands it's a problem. But an unused declaration can be just the library's API.
n
Such a warning might still make sense if the code is labelled as an application instead of as a library. But even there it is often undecideable (e.g. there could be some reflection-based invocation of methods e.g. for an app implementing an HTTP server)
d
I see, thanks!