http://blog.csdn.net/jmyue/article/details/11110857
Big projects need to be done by more than one group, but everyone has their own coding habits, and even a lot of them are incorrect. So how do you make all of your team's developers follow certain coding specifications to ensure that your project code style is consistent? It would be a tedious and time-consuming task to require each developer to check their code against the coding specifications before submitting the code. Checkstyle is an open source code analysis tool that can help developers ensure that their code follows certain code specifications. Checkstyle, by constantly checking your code, immediately prompts for violations of defined code specifications so that developers can discover and modify irregular code in a timely fashion. The Checkstyle plug-in in Eclipse is Eclipse-cs. 1. Install Checkstyle plugin
On the Eclipse menu bar, select Help-> Install New Software ... to enter the following installation interface:
Click "Add ..." to open the Add Repository dialog box and click "OK" to enter name and location.
Select the jautodoc you just added and click "Next >" until the installation is complete. 2. Configure Checkstyle
On the Eclipse menu bar, select Window-> Preferences-> Checkstyle to enter the following settings interface:
In the Global Check configurations box, lists the check configurations that you can select (check Configuration), and the default bar, which is marked as the defaults for the tick.
If you want to configure your own check options, you can click the "New ..." button to create a new configuration and enter the following check configuration interface:
Check the type of configuration, you can have a variety of options. The Internal configuration type is to check that the configuration exists within Eclipse, and that the External configuration type is equivalent to importing an existing XML configuration file. The Checkstyle configuration is an XML file.
If you want to modify an existing configuration, you can click the "Configure ..." button to open the Checkstyle Configuration dialog box and modify it as needed. 3. Use of Checkstyle
Checkstyle will constantly check code specifications during code development, including: Javadoc annotation naming convention header Import size white space modifier code class design
Following this code after Checkstyle check, the code does not conform to the specification, the background will be marked as light yellow to hint. Clicking on the cue tag of the wardrobe will show you where the specific specifications are not met. Examples are shown in the following illustration:
Reference
Checkstyle website
Checkstyle Eclipse Plugin website