Can any of the existing source code analzyers provide metrics on where code is used? I'm trying to find code that is either unused or consumed only by tests, basically candidates for deletion.
-
@laune unused in the class path – xenoterracide Aug 05 '14 at 17:38
-
If an API has been designed according to sound design principles, "unused" is not something to be removed immediately. – laune Aug 05 '14 at 17:40
-
@laune meeting ridiculous test coverage metrics, looking to see if all the covered/unconvered things really need to be that... – xenoterracide Aug 05 '14 at 17:45
5 Answers
In IntelliJ (for example), you can use the Inspections which can point out the unused methods. You will find some details there: How to use IntelliJ IDEA to find all unused code?
If you want to scan a set of projects, you can also use Sonar, an open source platform for Continuous Inspection of code quality. It provides a few plugins for finding dead code, such as this one.

- 1
- 1

- 813
- 8
- 16
There is an eclipse plugin called CodePro AnalytiX from google developer tools which has the capability of dead code analysis. Click here

- 522
- 5
- 15
PMD is a standalone analyzer with plugins for several IDE's. It can analyze java, javacript, android etc. and find unused code.

- 366
- 1
- 15
(sorry cannot comment yet)
What environment do you use for development? I use Eclipse, which provide nice reporting on unused/unreachable code and imports. Just import your project into eclipse, and you will see all the warnings in Problems view.
I hope it was helpful

- 358
- 3
- 11