`
meetrice
  • 浏览: 194050 次
  • 来自: 南京
社区版块
存档分类
最新评论

Eclipse插件CheckStyle安装以及使用

阅读更多
Eclipse插件CheckStyle安装以及使用
第一部分Checkstyle的使用
介绍 Checkstyle是一个开发工具,可以帮助编程人员编写符合编码规范的java 代码 。程序员都非常讨厌程序的check工作,checkstyle能够自动地完成这项烦琐但又非常重要的工作 ,从而节省了的程序员的时间,也提高了检查的质量。Checkstyle已经成了加强编码规范的首选工具。 NtCheckstyle 是一个可安装的模块,它自动完成Checkstyle和Netbeans 环境的集成。集成后checkstyle的使用非常的方便。 安装 你可以在Netbeans中直接安装NbCheckstyle。
第二部分checkStyle安装
方法一:通过更新网页
1。在Eclipse中,选择Help->Software Updates->Find and Install
2.选择 Search for new features to install 选择Next
 
3.选择 New Remote Site
4.         在名称中输入 Checkstyle Plug-in,在URL中输入:
http://eclipse-cs.sourceforge.net/update
5.         然后继续安装就行了。
 
方法二:
 1。你可以自己从Eclipse Checkstyle Plug-in's SourceForge project page 下载安装包,最新版的(2007/4/2)为4.3.0。
下载到之后,把里面的两个文件夹plugins和 features下面的文件分别放到eclipse 目录下面对应的plugins和features目录下。(别弄错了哦^_^)
2。清千万注意了,如果你就这样直接启动eclipse 可能会出现ClassNotFoundExceptions 等错误。你必须在启动eclipse的时候加上一个参数 -clean. 这样eclipse就可以更新它当前安装的许多插件信息。比如你得eclipse在d盘 那么就是 d:\eclipse\eclipse.exe -clean
Important Note: As of plug-in release 4.0.0 only Eclipse 3.0 and newer is supported. Eclipse 2.x.x support is discontinued. Please use older plug-in versions with Eclipse 2.x.x. - downloadable from the SourceForge Project Page (不翻译了)
 
安装完毕!
 
 
第三部分 checkStyle 使用
1。启动eclipse
2. Open the properties of the project you want to get checked
打开你要检查的项目的属性
 
3.Select the Checkstyle section within the properties dialog
在对话框中选择你要的checkStyle项目
 
 
请注意不要忘记了在左上角那个box打勾。如图。
4。接下来就可以看看你的代码符合规范与否了
 
5。如果看到上图的效果
   小弟恭喜你了!安装成功了。
 
第四部分 Checkstyle的结果输出
序号      输出内容意义
1 Type is missing a javadoc commentClass  缺少类型说明
2“{” should be on the previous line “{” 应该位于前一行
3Methos is missing a javadoc comment方法前面缺少javadoc注释
4Expected @throws tag for “Exception”在注释中希望有@throws的说明
5“.” Is preceeded with whitespace “.” 前面不能有空格
6“.” Is followed by whitespace“.” 后面不能有空格
7“=” is not preceeded with whitespace“=” 前面缺少空格
8“=” is not followed with whitespace“=” 后面缺少空格
9“}” should be on the same line“}” 应该与下条语句位于同一行
10Unused @param tag for “unused”没有参数“unused”,不需注释
11Variable “CA” missing javadoc变量“CA”缺少javadoc注释
12Line longer than 80characters行长度超过80
13Line contains a tab character行含有”tab” 字符
14Redundant “Public” modifier冗余的“public” modifier
15Final modifier out of order with the JSL suggestionFinal modifier的顺序错误
16Avoid using the “.*” form of importImport格式避免使用“.*”
17Redundant import from the same package从同一个包中Import内容
18Unused import-java.util.listImport进来的java.util.list没有被使用
19Duplicate import to line 13重复Import同一个内容
20Import from illegal package从非法包中 Import内容
21“while” construct must use “{}”“while” 语句缺少“{}”
22Variable “sTest1” must be private and have accessor method变量“sTest1”应该是private的,并且有调用它的方法
23Variable “ABC” must match pattern “^[a-z][a-zA-Z0-9]*$”变量“ABC”不符合命名规则“^[a-z][a-zA-Z0-9]*$”
24“(” is followed by whitespace“(” 后面不能有空格 25“)” is proceeded by whitespace“)” 前面不能有空格
 
分享到:
评论
2 楼 zhuxinyu 2009-02-28  
感谢 checkstyle 安装成功
1 楼 cniao83 2008-10-22  
很强大  

相关推荐

Global site tag (gtag.js) - Google Analytics