|
Written by Boris Baldassari
|
|
Friday, 26 March 2010 23:01 |
|
Java projects are checked using external tools; namely PMD, Checkstyle and TaskFinder.
This article describes the methods and tools used for the continuous integration services of Java projects.
Process
We usually use the following process to build, test and extract metrics.
- First get new updates from configuration management.
- Clean, Build, get Javadoc with Ant or Maven targets.
- Run tests if any -- not all projects have unit or system tests.
- Run PMD
- Publish reports, javadoc, binaries, fingerprints..
PMD
PMD website: http://pmd.sourceforge.net
PMD scans Java source code and looks for potential problems like:
- Possible bugs - empty try/catch/finally/switch statements
- Dead code - unused local variables, parameters and private methods
- Suboptimal code - wasteful String/StringBuffer usage
- Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
- Duplicate code - copied/pasted code means copied/pasted bugs
The rulesets used in our tests are the following:
- basic: the Basic Ruleset contains a collection of good practices which everyone should follow.
- sunsecure: these rules check the security guidelines from Sun, published at java.sun.com/security/seccodeguide.html.
- unusedcode: the Unused Code Ruleset contains a collection of rules that find unused code.
|