日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Findbugs安裝使用文檔

系統 1992 0

一、簡介

?????? Findbugs 是一個靜態分析工具,它檢查類或者 JAR 文件,將字節碼與一組缺陷模式進行對比以發現可能的問題。利用這個工具,就可以在不實際運行程序的情況對軟件進行分析。它可以幫助改進代碼的質量。

?????? Findbugs 提供了方便操作的可視化界面,同時也可以作為 Eclipse 的一個插件來使用,而我們使用得最多的還是作為 Eclipse 的插件來使用。

二、使用方法

?????? Findbugs 可以通過三種方法使用,可以通過 Ant 工具,通過 Ant 提供的 Swing 操作界面和作為 Eclipse 的一個插件來使用。

1. Ant工具

Ant是一個很好的Java自動執行工具。

???????? Findbugs 官方提供了 Ant findbugs 操作方法,我們可以通過這樣一個 build.xml 文件來使用 findbugs

<project name=" 項目名 " default="all">

<property name= "findbugs.home" value= "findbugs 解壓路徑 " />

???????? ???? <path id= "findbugs.path" >

???????? ???????? <fileset dir= "findbugs 解壓路徑 " >

?????????????????? ???? <include name= "**/*.jar" />

????????????? ???? </fileset>

???????? ???? </path>

???????? ???? <taskdef name= "findbugs"

????????????? ???? classname= "edu.umd.cs.findbugs.anttask.FindBugsTask"

????????????? ???? classpathref= "findbugs.path" />

???????? ???? <!-- ? 定義 findbugs home findbugs task 要使用 ? -->

???????? ???? <target name= "findbugs" >

????????????? ???? <findbugs home= "${findbugs.home}"

?????????????????? ???? output= "xml:withMessages" outputFile= " 生成的文件 " >

?

?????????????????? ???? <!-- ? 以上定義 findbugs 查找的類路徑 ? -->

?????????????????? ???? <auxClasspath path= "${findbugs.home}/lib/findbugs-ant.jar" />

?????????????????? ???? <auxClasspath>

?????????????????????? ???? <fileset dir= "lib"

??????????????????????????? includes= "*.jar" />

?????????????????? ???? </auxClasspath>

?????????????????? ???? <sourcePath path= " 源文件路徑 " />

???? ????? ??????? ???? <class location= " 生成類路徑 " />

????????????? ???? </findbugs>

???? ???? </target>

???? </project>

比如:我這里有一個我放在博客上的項目的findbugs的ant操作的build文件。

<project name="Calendar" default="all">

<property name= "findbugs.home" value= "../../findbugs-1.3.8" />

???????? ???? <path id= "findbugs.path" >

???????? ???????? <fileset dir= "../../findbugs-1.3.8" >

?????????????????? ???? <include name= "**/*.jar" />

????????????? ???? </fileset>

???????? ???? </path>

???????? ???? <taskdef name= "findbugs"

????????????? ???? classname= "edu.umd.cs.findbugs.anttask.FindBugsTask"

????????????? ???? classpathref= "findbugs.path" />

???????? ???? <!-- ? 定義 findbugs home findbugs task 要使用 ? -->

???????? ???? <target name= "findbugs" >

????????????? ???? <mkdir dir= "target/findbugs" />

????????????? ???? <findbugs home= "${findbugs.home}"

?????????????????? ???? output= "xml:withMessages" outputFile= "target/findbugs/calendar-fb.xml" >

?????????????????? ???? <!-- ? 以上定義 findbugs 查找的類路徑 ? -->

?????????????????? ???? <auxClasspath path= "${findbugs.home}/lib/findbugs-ant.jar" />

?????????????????? ???? <auxClasspath>

?????????????????????? ???? <fileset dir= "lib"

??????????????????????????? includes= "*.jar" />

?????????????????? ???? </auxClasspath>

?????????????????? ???? <sourcePath path= "src" />

???? ????? ??????? ???? <class location= "target/classes" />

????????????? ???? </findbugs>

???? ???? </target>

???? </project>

設置好 Ant 的環境后,在命令中使用 ant -f build.xml ,或者在 Eclipse 直接運行 build.xml 文件,運行后生成了一個 xml 文件,如果你想用 Html 的格式查看 findbugs 的結果,可以把 output 屬性設為: html 。這樣就可以通過 Html 來查看 findbugs 的結果了。

2. 提供的 Swing 工具

?????? Ant操作是專家級的操作,一般對于Java不是很熟悉的人,寫build.xml文件。比起 Ant 來,使用 Findbugs 提供的 Swing 工具會使 Findbugs 的操作更加簡單。運行 Findbugs 解壓包中的 bin 文件夾下的 findbugs.bat 文件。

Findbugs Swing 工具初始主界面如下:

?

在分析項目之前,我們必須要新建一個項目來分析,選擇文件 -> 新建

顯示新建項目的界面如下圖:

?

?


然后添加要分析的類包和目錄(可以選擇編譯好的類所在的文件夾,也可以選擇生成的 jar 包),再添加輔助類所在的文件夾和源文件所在的文件夾( java 文件所在的文件夾)。再點擊完成就可以建立一個要分析的項目。

?

Findbugs安裝使用文檔

建立項目后,會自動先自動開始解析項目。

解析后界面:

? Findbugs安裝使用文檔

其中左邊是缺陷的樹結構列表,點擊其中一個 Bug ,可以在右邊的界面中,顯示 Bugs 的源文件以及所在的位置。

2.3 ???????? Findbugs Eclipse 插件

Eclipse的Findbugs 插件,可以將 Findbugs 集成到 Eclipse 中使用。

2.3.1 ??????? Findbugs Eclipse 插件安裝方法

??????? 1. ????? 在線安裝

安裝地址: http://findbugs.cs.umd.edu/eclipse

??????? 2. ????? 離線安裝

下載 Findbugs 插件,將它放入 Eclipse 下的 plusin 文件夾,然后重啟 Eclipse

?

??????? 2.3.2 ??????? Findbugs Eclipse 插件使用

???????? 安裝了 Findbugs 插件后。右擊點擊你要檢查的項目選擇【 Find Bugs -> Find Bugs 】進行檢查。

??????? 要查看 Findbugs 檢查出了哪些 Bug ,可以選擇 Windows 菜單 ->Show View->Bug Explorer ,打開 Bug Explorer 面板。

???????? 如果想要查看某個 Bug 詳細的信息,則可以選擇 Windows 菜單 ->Open Perspective ,然后選擇 FindBugs 就可以打開 FindBugs Properties 面板,在這個面板里面可以看到最詳盡的 Bugs 信息。

?

?

Findbugs安裝使用文檔


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 兰溪市| 莱阳市| 上高县| 开封县| 彭山县| 海原县| 南部县| 阿坝县| 延安市| 新乐市| 永平县| 晴隆县| 邵武市| 襄汾县| 彭州市| 杨浦区| 阜阳市| 蒲江县| 馆陶县| 绥化市| 色达县| 通道| 治县。| 兴海县| 新竹县| 咸丰县| 平山县| 新巴尔虎左旗| 多伦县| 无棣县| 凤庆县| 拉孜县| 大同市| 茌平县| 阜阳市| 乌拉特后旗| 磐安县| 兴隆县| 东宁县| 祁连县| 潜山县|