Installation and use of Checkstyle on eclipse

Source: Internet
Author: User
Tags checkstyle
1. Overview

With the establishment and implementation of code specifications for the center, the project team's knowledge of code specification requirements, and the importance of software engineers to the coding of their own code, "code specification" has become a central "hot word". Then how to write a code of norms, how to develop coding standard habits. I believe a lot of people know checkstyle This coding specification tool, this article describes the installation process of Checkstyle in Eclipse, and how to use it. Hope that through this article, so that everyone can easily and quickly grasp the checkstyle. 2. Knowledge of Checkstyle

Checkstyle is a project under SourceForge that provides a tool to help Java developers comply with certain coding specifications. It automates the code-checking process and frees developers from this important but tedious task. It can check the code according to the set coding rules. For example, the specification of variable naming, method body maximum number of lines, duplicate code checking and so on.

If your project manager says in a meeting: "I want our code to be written like a human!", then using Checkstyle is definitely the right choice. 3. Resource Description

checkstyle:http://sourceforge.net/projects/eclipse-cs/


This article is an example of installing the latest version of the Checkstyle plugin on eclipse4.2. The location of Eclipse is downloaded after D:\Program Files\eclipse,checkstyle in D:\Sdk\checkstyle\net.sf.eclipsecs-updatesite_ 5.7.0.201402131929-bin.zip, which uses the Checkstyle rules file in D:\Sdk\checkstyle\style_template.xml

Resource Download Address:

http://download.csdn.net/detail/ccboy2009/7521353
4. Checkstyle Plug-in installation

Here are two ways to install Checkstyle on eclipse.

Ø Offline Installation

① Download Checkstyle offline installation package;

http://sourceforge.net/projects/eclipse-cs/


② the copy of the features folder and the Plugins folder in the compressed package to the root directory in eclipse after the download is complete;


③ opens Eclipse,window-->preferences, if the Checkstyle menu appears in the list, the installation is successful.

Note: If you are prompted for exception information such as ClassNotFoundException when you start Eclipse, you can start with a "-clean" parameter.


Ø Online Installation

Be aware that the network is unblocked during the installation process, which can cause installation failures if the network is unstable.

Help--> Install New Software

Checkstyle Plugin Address: http://eclipse-cs.sourceforge.net/update


Next-->next--> Select I Accept ... Finish. The Checkstyle plugin will begin to install.

During the installation process, you may receive a warning prompt and select OK.


After the installation is complete, reboot the Eclipse,checkstyle as prompted to complete the installation. 5. Checkstyle Global Configuration

Window-->preferences, select the Checkstyle menu, increase the team uniform rules file, and set it as the default rule. The following figure:


To this global configuration is complete. 6. Checkstyle Project configuration

Project--> Right Key properties


To this project configuration is complete. Success, Checkstyle has already begun to work.


The discovery project has many red forks, indicating that the code is the result of compliance with the specification.


There is no hint of red when the information is modified.


7. Other Operations

In the project right-click menu, Checkstyle also has some quick actions, as shown in the following figure:

8. Conclusion

Through the reading and learning of this article, I believe you have a certain understanding and familiarity with the Checkstyle coding standard tool. But to standardize their code to write rules, the project team to unify the code within the group, only rely on this tool is not, we need to adhere to the use of this tool, gradually will form a habit, and eventually abandoned Checkstyle can still write the code of norms.

Related Article

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.