Use of checkstyle

Source: Internet
Author: User
Tags checkstyle

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/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.