|Checkstyle is an open-source development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code. It is ideal for projects that want to enforce a coding standard. Checkstyle is a code checker and not a code fixer. If you need a code fixer you could use Jalopy.
Checkstyle is highly configurable and can be made to support almost any coding standard. Configuration files are supplied to support well known coding standards such as the Sun Code Conventions for the Java Programming Language.
Checkstyle is released under the GNU Lesser General Public License (LGPL).
Checkstyle can check for:
More information about Checkstyle can be found at:
- Javadoc Comments
- Naming Conventions
- Size Violations
- Miscellaneous Checks (including some useful checks like unnecessary System.out and printstackTrace)
Plug-ins are written to integrate Checkstyle with an IDE, such as Eclipse / WebSphere Studio Application Developer (WSAD).
The latest Eclipse Checkstyle plug-in version can be downloaded from:
Installing Eclipse Checkstyle v3.1 on WSAD
Operating system used
Windows XP Home Edition Version 5.1 SP 2
WebSphere Studio Application Developer
- Download and unzip com.atlassw.tools.eclipse.checkstyle_3.1.1.zip
- If you had a pre 3.1.0 version of the Eclipse Checkstyle plug-in installed you will need to remove it before installing the new plug-in. Also, remove any .checkstyle files from the root of your projects, these files are not compatible with this version of the plug-in.
See: C:\Documents and Settings\<user>\
After removing these files be sure and refresh your workspace so that Eclipse is aware that they have been removed.
- Copy the new com.atlassw.tools.eclipse.checkstyle_<version> plug-in folder to ..\WebSphere Studio\eclipse\plugins\
- Restart WSAD if its already running.
- To enable Checkstyle on a project right-click the project and select the project's properties.
- Select the project's Checkstyle properties in the left column and enable the check-box and select OK.
- As your code is compiled Checkstyle reports any problems it finds in the workbench Tasks window along with placing a marker next to the line with the problem in the source code editor. To go to the line of code with the problem just double click on the message in the Tasks window.
- Often you don't want all files within a project inspected. You can filter these files out so they are not inspected by creating a file filter. A file filter is a regular expression that is used to exclude file. The regular expression operates on the complete file name within the project, so folder names can be used in the expression.
In the example above the file IntSessionWrapper is checked. To disable the inspection for this file, add the filename in the File Filters window.
- The Checkstyle core engine can be configured to check for a number of different items in your code. The Checkstyle plug-in can be configured through the menubar: Window | Preferences screen.
- The full set of properties that can be specified can be found in the Checkstyle configuration page (see ..\WebSphere Studio\eclipse\plugins\
com.atlassw.tools.eclipse.checkstyle_2.1.0\doc\csdocs\config.html) of the core engine documentation (see ..\WebSphere Studio\eclipse\plugins\
- Using the Import/Export buttons the Checkstyle configuration properties can be imported/exported to/from a properties file. This file can then be distributed amoung a team of developers or used to run the Checkstyle core from the command line.