Java code Analytic/Metrics tool

5.3k views Asked by At

I am looking for a free Java code analysis/metrics tool that I can use to see class dependencies, method execution times, etc, and possibly to print out a diagram that shows them. I am currently using a jdepend task in ANT to achieve this, but I'm thinking there must be a better tool for that sort of thing. I would also prefer if it was integrated with Netbeans, since I'd rather not port all my projects to Eclipse for the task of analyzing. I have tried to play with the community version of Visual Paradigm, but I got sick of it really fast when it didn't offer code synchronization in the community edition. Although I can give it another shot if that is indeed the way to go. I also tried BOUML, but it seems to be more of a UML design tool than an existing code analyzer. So, my question is, what do you guys use for Java code analysis? Thanks!

EDIT: For instance, JDepend measures a few metrics and can draw a nice little dependency graph, but it doesn't exactly have a UI or anything. I guess I'm looking for a tool that can draw out all my classes and their dependencies on each other (jdepend only does packages AFAIK) as well as the methods that are called between the classes and provides a metric number of "how good the code structure is". I apologize if the question is vague, I'm just looking for a variety of options and I don't exactly have a lot of experience with code metrics tools...

2

There are 2 answers

0
Mike On BEST ANSWER

As @Victor has mentioned Sonar is a very good tool for static code analysis. It produces graphs, charts, and generally allows you to slice and dice your Java code analysis in multiple ways.

However, it does run as a server, which can require privileges on your machine/network that you might not have. I use it myself, and I recommend it, but it's not always practical. So let's take a look at some of the tools that it uses underneath the hood.

First, there's FindBugs. As the name implies, it helps you find bugs in your Java source code.

Next, there's PMD. It helps find bugs in different ways from FindBugs.

Third, there's CheckStyle. It helps ensure that your code conforms to certain style guidelines.

Finally, there's Cobertura, which instruments your Java bytecodes and analyzes which source code lines are exercised by your unit tests (you do have unit tests, right?)

This is not an exhaustive list of the tools that Sonar employs, but it covers what seem to be the highlights. Inside Sonar, these are all 100% configurable. Outside Sonar, they're still configurable, but you better like XML.

0
Victor Sorokin On

Sonar. Though, personally I've never used it, so I can't answer questions about details. However, I know that our conitnuos building tool is integrated with it to make pretty pictures :)