Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java code Analytic/Metrics tool

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

like image 623
SuperTron Avatar asked Dec 01 '11 16:12

SuperTron


People also ask

Is Maven code analyzer tool?

Static Code Analysis Tool The Static Code Analysis Tools is a Maven plugin that executes the Maven plugins for SpotBugs, Checkstyle and PMD and generates a merged . html report. It is especially designed for openHAB to respect the defined coding guidelines.

Which tool is used for code analysis?

Source code analysis tools, also known as Static Application Security Testing (SAST) Tools, can help analyze source code or compiled versions of code to help find security flaws. SAST tools can be added into your IDE. Such tools can help you detect issues during software development.

What is SonarQube used for?

SonarQube (formerly Sonar) is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells on 29 programming languages.


1 Answers

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.

like image 116
Mike Avatar answered Sep 25 '22 21:09

Mike