Really big projects require the input of hundreds of programmers, often geographically dispersed and with great differences in skill level.
Code reviews are essential to code quality, but no team wants to review tens of thousands of lines of code, or should have to.
In many cases, a QA team is assigned to review this code manually, based on coding standards used as guidelines for development.
How to overcome the challenges associated with code reviews by automating them?
Manually reviewing millions of lines of code is a tedious job, though; ultimately as exhausting as it must be exhaustive.
|
Java™ Application Development on Linux® – Free 599 Page eBook |
Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications: |
||||
Smart teams don’t do code reviews manually: instead they rely on source code analyzers like Checkstyle, PMD, and JTest.
Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.
Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions.
A good example of a report that can be produced using Checkstyle and Maven can be seen here.
Another Example is:
Usage:
Checkstyle is built in a JAR file which can run inside a Java VM or as an Apache Ant task. It can also integrate into an IDE or other tools.
n Checkstyle is highly configurable and can be made to support almost any coding standard.
n Checkstyle configuration
A Checkstyle configuration specifies which modules to plug in and apply to Java source files. Modules are structured in a tree whose root is the Checker module. The next level of modules contains:
* FileSetChecks – modules that take a set of input files and fire error messages.
* Filters – modules that filter audit events, including error messages, for acceptance.
* AuditListeners – modules that report accepted events.
For more details Click Here.
n It can be used as:
u An Ant task.
To use the task in a build file, you will need the following taskdef declaration:
<taskdef resource="checkstyletask.properties" classpath="/path/to/checkstyle-X.jar"/>
u A command line tool.
The command line usage is:
java -D= com.puppycrawl.tools.checkstyle.Main -c [-f] [-p] [-o] [-r
] file...Checkstyle will process the specified files and by default report errors to standard out in plain format. Checkstyle requires a configuration XML file that configures the checks to apply. Command line options are:
-f format- specify the output format. Options are"plain"for the DefaultLogger and"xml"for the XMLLogger. Defaults to"plain".-p propertiesFile- specify a properties file to use.-o file- specify the file to output to.-r dir- specify the directory to traverse for Java source files.
n Checkstyle is often used as an Eclipse plugin, and also as part of a project build to create a report of coding-standard violations.
n It can be downloaded at:
http://checkstyle.sourceforge.net/
Features:
The things that Checkstyle can check for are:
v Javadoc Comments
v Naming Conventions
v Headers
v Imports
v Size Violations
v Whitespace
v Modifiers
v Blocks
v Coding Problems
v Class Design
v Metrics Checks
- BooleanExpressionComplexity
- ClassDataAbstractionCoupling
- ClassFanOutComplexity
- CyclomaticComplexity
- NPathComplexity
v Miscellaneous Checks
v Optional Checks
Reference:
http://checkstyle.sourceforge.net/
http://en.wikipedia.org/wiki/Checkstyle
http://eclipse-cs.sourceforge.net/
http://checkstyle.sourceforge.net/cmdline.html
http://checkstyle.sourceforge.net/anttask.html
http://www.javaworld.com/javaworld/jw-11-2008/jw-11-checkstyle1.html
Related articles
- Checkstyle~A static code analysis tool (clean-clouds.com)
- Java Notes - 1 (clean-clouds.com)
- Frequently Asked Questions in Java Part-2 (clean-clouds.com)
- Frequently Asked Questions in Java Part-1 (clean-clouds.com)
- Maven~Software Tool for Project Management and Builds Automation (clean-clouds.com)
- Java Coding Standards (clean-clouds.com)
- Introduction to ANT (clean-clouds.com)














Pingback: Maven~Software Tool for Project Management and Builds Automation | Researcher's Blog (Informative)
Pingback: How to install Ant? | Researcher's Blog (Informative)
Pingback: Introduction to ANT | Researcher's Blog (Informative)
Pingback: Built-in Tasks in Ant | Researcher's Blog (Informative)
Pingback: ANT Overview, Structure & Basics (Build File) | Researcher's Blog (Informative)