1. Introduction
Checkstyle is an open-source project under SourceForge. It provides a tool to help Java developers comply with certain coding specifications. It can perform automated code specification checks, freeing developers from this important but boring task.
Checkstyle is highly configurable, which allows it to support almost all programming specifications.
This article describes how to use the plug-in eclipse.
2. Installation
1) eclipse automatic installation address
Http://eclipse-cs.sf.net/update/
2) manual Installation
--: Http://sourceforge.net/projects/eclipse-cs/files/OldFiles/
-- Copy the files in the decompressed features and plugins directories to the corresponding directory under % eclipse_home %.
-- Restart eclipse
3. Use
-- Automatic check:
Right-click the target project --> checkstyle --> activate checkstyle
-- Manual check:
Right-click the target project/directory/file --> checkstyle --> check code with checkstyle
-- View error:
Windows --> show View --> checkstyle violations
4. Common Errors
-- Package javadoc: Missing package-info.java file.
Package-info.java file missing
About package-info.java: http://blog.csdn.net/antswallow/article/details/6277079
-- New line at end of file: file does not end with a newline.
The last line of the file does not end with a new line
-- Type javadoc: missing a javadoc comment.
Javadoc annotation missing
-- Regexpsingleline: line has trailing spaces.
The row ends with a blank character.
-- Style javadoc: First sentence shoshould end with a period.
The first sentence must end "."
-- File Tab character: file contains TAB characters (this is the first instance ).
Contains the Tab character, replacing the tab with the method: http://hi.baidu.com/lane727/blog/item/bd6304fb7cb48555242df27f.html
-- Whitespace around: '{' is not preceded with whitespace.
No space before "{"
More error cause lookup: http://checkstyle.sourceforge.net/availablechecks.html
5. References
Http://checkstyle.sourceforge.net/