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.
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.
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.
Another Example is:
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 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
-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:
The things that Checkstyle can check for are:
v Javadoc Comments
v Naming Conventions
v Size Violations
v Coding Problems
v Class Design
v Metrics Checks
v Miscellaneous Checks
v Optional Checks
- 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)