關於 CheckStyle 的使用 ( Eclipse 插件 )

 

1.下載eclipse插件

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

下載後,把裏面的兩個文件夾plugins和 features下面的文件分別拷貝到eclipse目錄下面對應的plugins和features目錄

2.如果你就這樣直接啓動eclipse 可能會出現ClassNotFoundExceptions 等錯誤,所以必須在啓動eclipse的時候加上一個參數 -clean. 這樣eclipse就可以更新它當前安裝的許多插件信息

比如你得eclipse在d盤 那麼就是 d:\eclipse\eclipse.exe -clean 

 

checkStyle 使用

選中工程,右鍵選擇checkstyle->check code with checkstyle,檢查錯誤即可

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“)” 前面不能有空格



當然,最後你也可以定義自己的 check style 來檢查項目。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章