We have many applications running (consider all of them run on Java Platform) and we need to check which ones were used in the last, say, 3 months, and, among those active applications, which parts/functionalities (and how often) are still being used. Is that possible?
The goal here is to detect applications or funcionalities which no longer are relevant to the business and remove them, so that we end up having less code to maintain and monitor.
Is there any tool which could help us achieving that?
We DO use agile methods, so when a new application gets into production it has only the funcionalities which are important to the business, but sometimes some features of this application expires (for different reasons), so we would like to have a way of identifying that.
There are at least two tools you can deploy along your application and collect some statistics, even in production:
AspectJ - weave all classes and somehow log every method execution.
JaCoCo - essentially does the same thing but automatically with a help of a Java agent. Executed methods/branches (in fact, this is a code coverage tool) are saved in a file for future processing. Should solve your problem pretty easy.
Both approaches should work with any JVM language (I see jruby in your question) as they work on bytecode level. I once used JaCoCo to measure code coverage (think: which methods/branches were execured) during Selenium test run.
For example, Intellij IDEA has static analysis which greys out names of Types/Methods which aren't called. If you want automatic tool for that, try Sonar. I guess, both of these methods can give a few false results if you use reflection in some form.
There is also PMD
btw it could be installed as a plugin for different IDEs
I'm also using the following static analysis tools:
UCDetector (open source eclipse plugin) - can be quite helpful.
Structure101 (commercial software)- can be used for that purpose (e.g. finding unused classes), too.
You can use JArchitect tool to analyse your code and detect the unused code and functionnalities, there are some of it's functionnalities :
- Code Query language (CQLinq),
- more than 80 Metrics,
- and display analysis results in different types of Diagrams