Is there any tool to detect code/functionality whi

2019-05-27 01:35发布

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.

5条回答
神经病院院长
2楼-- · 2019-05-27 02:01

There are at least two tools you can deploy along your application and collect some statistics, even in production:

  1. AspectJ - weave all classes and somehow log every method execution.

  2. 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 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.

查看更多
放我归山
3楼-- · 2019-05-27 02:07

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.

查看更多
smile是对你的礼貌
4楼-- · 2019-05-27 02:09

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
查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-05-27 02:13

There is also PMD

btw it could be installed as a plugin for different IDEs

查看更多
甜甜的少女心
6楼-- · 2019-05-27 02:15

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.

查看更多
登录 后发表回答