Why using a code guidelines checker?
These tools are highly recommended across a team of different developers for the following reasons:
- These tools are highly configurable and can be made to support almost any coding standard.
- Ideal for projects that want to enforce a coding standard (ideally where not all developer code the same way)
- Ease your debugging and maintenance costs by making the code more readable: developers do not have to worry about
deciphering individual coding styles when working on a piece of code they did not write.
- They can detect possible bugs or dangerous coding behavior - empty try/catch/finally/switch statements
- Detect dead code - unused local variables, parameters and private methods
- Sub optimal code - wasteful String/String Buffer usage
- Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
- Duplicate code - copied/pasted code means copied/pasted bugs
- Find class design problems, bug patterns like double checked locking.
They give an immediate "objective" feedback and help developers recognize where they have been excellent or lazy;
It gives team leader, an opportunity to study the code, design and team from a different perspective; and by slicing off
whole classes of faults, You can concentrate more on design shortcomings.
All code checker share more or less the same features
- Violations severity can be defined at rules level (error, warning, ignore, other).
- Rules can be triggered by threshold/values.
- Rules are stored in XML files.
- Java editor highlight offending lines/rules in violation
- Rules can be extended (require some strong tree parsing and language knowledge)
- Integration in major IDE (eclipse, IDEA, ...)
- Integration in ANT, Maven, ...
The major issues wont be to install these tools...
Most developers are convinced that their code is the best, and bad habits are difficult to get rid of. The
biggest pain will be to force all developers to agree on a set of common rules that you want to enforce.
A good starting point is to use some well known rules or good practices from the industry. Sun is for example
publishing some code writing rules.
I will look at the major open source and free code checker on the market in this series of articles:
- Code coverage
- Next >>