• Post Reply Bookmark Topic Watch Topic
  • New Topic

Command line tool for Java unused code analysis?  RSS feed

 
Tim Cooke
Marshal
Posts: 4044
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day Ranchers,

Do you know of a command line tool that will analyse a Java project, using Maven if that's important, and report all unused code?

I've tried the built in tool that comes with IntelliJ but it's a large project and it takes ages and ages and I'm starting to think it's never going to complete (18 hours so far).

Cheers, Tim
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might have already seen these but it looks like SonarQube has something to do that. I don't know if there's any option to run as a separate process from the command line. That page also mentions CheckStyle, PMD, and FindBugs so those may have limited capabilities as well.
 
Tim Cooke
Marshal
Posts: 4044
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that Junilu.

I half mentioned Maven before but in actual fact that's central to my problem. I'm looking for a tool that will report unused public methods and classes across a multi module Maven project.

The scenario I have is that we have been able to remove an entire module from the project and now want to find all the supporting dead code existing in other modules. The manual approach is unfeasible and intelliJ doesn't seem to be able to handle a full project analysis and just hangs.

Ideally I'd like a command line tool, or some standalone tool, that I can kick off and let run in the background.
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barring the existence of such a tool already, I wonder if there's any way to hook into Eclipse's ability to find references to methods and list them out. IntelliJ IDEA probably has a similar feature that you might be able to hook into from a plugin. Then it'd be a "simple" matter of subtracting that set from the set of all public methods to find which ones have no references.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!