Code Quality Tools in Java
Join the DZone community and get the full member experience.Join For Free
there are several tools to measure the code quality. the ones i have tried with a lot of success are:
(latest version 1.3.8) –
uses static analysis to look for bugs in java code
this is a great tool, it discovered possible nullpointerexceptions and
a lot more bugs in my projects. sometimes i asked myself how this
program could have discovered this ‘complicated’ bug.
with the maven plugin
you can do:
which will use version 1.3.8 out of the box
(latest version 4.2.5) –
scans java source code and looks for potential problems
the rules are configurable, but at the beginning you will only need the
provided one (and spend a lot of time to choose your favourites
netbeans 6.5 this tool
is well integrated and works like a charme (ctrl+alt+p).
with the maven plugin you can do:
after you specified the following in the pom.xml under<reporting> <plugins> :
other tools could be
- jaranalyzer – is a dependency management utility for jar files. it’s primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files.
- hammurapi – a code quality governance platform
but i haven’t tried them so far.
for findbugs and pmd there is a netbeans plugin ( sqe … software quality environment ) which looks promising, but fails with a nullpointerexception after i installed it via the update center and tried it on my project. maybe i should use one of the snapshots . (btw: i successfully used the pmd-plugin and findbugs in the standalone version).
sonar is another interesting approach to use several code quality tools at a time. with sonar it is possible to see the violations or possible bugs over das or weeks – so, you are looking at the improvements and you will not get lost in the mass of bugs at the beginning. another “multi-tooling” project is xradar .
a little bit offtopic, but a great tool is proguard, which shrinks, optimizes, obfuscates and preverifies java class files. there is even a maven plugin for that.
Opinions expressed by DZone contributors are their own.