Does anyone know of a tool for detecting dead code in a Java EE project?
I've looked into lots of tools that do this well for pure Java projects, but nothing seems to really handle projects which include JSPs and Javascript files as well. For example, detecting that a Java method is in use because it's being called from a JSP, or detecting that some JSP file that previously was used as an AJAX request is no longer called from any Javascript.
Thanks.
What about real-life sampling? Plug-in JaCoCo agent to your application, run it and use it for a while. If you have thorough functional tests, run them. If you have a team of testers, let them click on your application. JaCoCo will record all executed lines (it is used for code coverage) in the meantime.
If some lines were not executed during extensive period of time (remember you would have to touch every possible screen, call, path and branch in your application) you should examine whether they aren't actually dead (or maybe you simply forgot to run your application in this particular configuration).
Understandably this is very fragile, but I don't think you will find anything automatic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With