Remove unused private classes
Hi,
I think that a recipe to remove unused private classes could be useful, similar to the existing org.openrewrite.java.cleanup.RemoveUnusedPrivateMethods recipe.
Cheers,
Tom
Hi Tom, This is a good suggestion
I have some experience with detecting unused (non private) methods and classes through ArchUnit. In practice there's a lot of caveats that are framework and project specific before you're able to say classes or methods are unused.
Like classes/methods only used in (de)serialization; classes and methods called by frameworks based on annotations; code that has unit tests, but nothing else calling it; classes that implement an interface and are discovered that way.
A lot of these details only show up once you start to implement such checks, and I think it would be quite hard to implement a defensive do-no-harm recipe that takes all this into account. Just thought I'd provide some insight here, before any naive attempts are made that might inadvertently break stuff.
Thanks Tim!