Introduction to CheckStyle
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. As well, other sample configuration files are supplied for other well known conventions.
Checkstyle can check many aspects of your source code.
Historically it' s main functionality has been to check code layout issues, but since the internal architecture was changed in version 3, more and more checks for other purposes have been added. Now Checkstyle provides checks that findclass design problems, duplicate code, or bug patterns like double checked locking.
Requirements
- Eclipse3.3 or later
- JRE/JDK1.5 or later
Installation
1. Download plugin
2. Update site
Start Eclipse and open a project.
Select "Help" - "Software Updates" - "Find and Install"
Click "Next", then click "New archived site" button.
Select the path of downloaded JAR file.
Click through the rest of the dialog boxes to install the plugin.
Using the Plugin
Right click on the java file or package or complete project and, choose Checkstyle - Check code with Checkstyle.
Open the file that you checked for violations. It will show the markers for the violations.
All the violations will be displayed in Checkstyle violations view along with their counts.
Bug description for CheckStyle
For Bug description, Visit : http://checkstyle.sourceforge.net/availablechecks.html
Customizing the rule set
Modify following file :
<eclipse-installation-dir> / Plugins / com.atlassw.tools.eclipse.checkstyle_4.4.3/sun_checks.xml
And comment following rules :
JavadocStyle, FinalParameters, GenericIllegalRegexp, LineLength, NoWhitespaceAfter,
NoWhitespaceBefore, WhitespaceAfter, WhitespaceAround, FileTabCharacter,TabCharacter
Example
<!--
<module name="JavadocStyle"/>
-->
Restart the eclipse and check for violations again.
|
No comments:
Post a Comment
Note: only a member of this blog may post a comment.