閱讀137 返回首頁    go 阿裏雲 go 技術社區[雲棲]


???????????????????????? FindBugs-??????-????????????-?????????

????????FindBugs??????????????????
??
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Chris Grindstaff?????????????FindBugs????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????false positives???????????????????????????????????????????????????????????????????????????????????????FindBugs??????????????David Hovemeyer?????William Pugh??????????????????????????????????????????????????????????????????????????????????????????????????????????????????FindBugs?????????????????????????????????????????????????????????????????????????????????????????????
FindBugs????????????
FindBugs??????????????????????????????????????????????????JAR??????(????????????????????????JAVA????????????????????????CLASS???)????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Visitor?????????????????????????????????????????1?????????????????????????????????????????????????????????????????????????????????????????????????????????
?????1. FindBugs UI
??

2.??????Eclipse???FindBugs??????

????????????????????????

https://findbugs.sourceforge.net/downloads.html

????????????????????????:

??????FindBugs????????????eclipse???blueJ????????????

The Eclipse plugin may also be obtained from one of the FindBugs Eclipse plugin update sites: --FindBugs??????????????????????????????????????????????????????????????????????????????

??????????????????????????????(??????).

???????????????????????????:

https://prdownloads.sourceforge.net/findbugs

???????????????zip???????????????????????????eclipse???plugin??????(<eclipse_install_dir>/plugins)???

?????????????????????????????????Help-->About Eclipse Platform-->Plug-in Details?????????FindBugs????????????????????????

3.???????????? ???Eclipse?????????FindBugs??????

??????FindBugs???????????????????????????????????????Java?????????????????????????????????Find Bugs?????????????????????FindBugs??????????????????????????????????????????????????????

???????????????FindBugs????????????????????????Java?????????????????????????????????FindBugs?????????????????????????????????????????????

??????????????? ??????/?????????????????????FindBugs????????????---??????????????????????????????FindBugs?????????

??????????????? ??????????????????????????????????????????bug?????????---??????????????????????????????????????????????????????????????????Medium??????????????????????????????Medium???Hign???????????????????????????????????????????????????????????????Style??????????????????????????????Style????????????????????????????????????

??????????????? ???????????????????????????????????????????????????detectors???

??????????????????????????????


(??????detectors?????????????????????FindBugs)


(?????????????????????)

??

????????????????????????

????????????????Correctness?????????????????????????????????????????????????????????bug??????????????????????????????????????????

?????????????????????????Bad??practice?????????????????????????????????????????????????????????????????????????????????????????????equals??????????????????hashCode????????????

?????????????????????????Multithreaded??correctness??????????????????????????????????????????

?????????????Performance??????????????????????????????

?????????????Security?????????????????????

?????????????Dodgy??????FindBugs?????????????????????????????????????????????bug?????????????????????

???Eclipse?????????FindBugs??????

????????????Eclipse??plugin????????????????????zip?????????

?????????????????????????????????Eclipse???Plugin??????

??????????????????Eclipse?????

??

???????????????????????MyEclipse8.5????????????????????????????????????????????????????????????Genuitec/MyEclipse??8.5/dropins????????

??

???Eclipse?????????FindBugs

????????????eclipse

??????FindBugs????????

??

??????Find??Bug????????

???????????????????????????????????????????????????-->Find??Bugs-->Find??Bugs???

check???????????????Bug??Explorer?????????????????????????????????????????????????????????????????

??

??????????????????????????????????????????????????????????????????????????????????????

??????FindBugs
??????????????????FindBugs????????????????????????????????
???????????????????????????????????=>??Properties??=>??FindBugs??=>

??

1??Run??Automatically??????

??????Eclipse??????????????????-----??????????????????Project---Build Automatically???????????????????????????.

?????????????????????FindBugs??????????????????Java????????????????????????????????????Eclipse???????????????????????????????????????Java???????????????FindBugs???????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????FindBugs????????????????????????

2??Detector??Configuration?????????
??????????????????????????????????????????????????????Bug??Pattern??????,????????????????????????????????????????????????????????????????

3??Minimum??priority??to??report?????????
?????????????????????????????????????????????????????????????????????Low???Medium???High??????????????????????????????????????????Log4J????????????????????????????????


????????????High???????????????????????????High???????????????????????????????????????
????????????Medium???????????????????????????Medium???High???????????????????????????????????????
????????????Low???????????????????????????????????????????????????????????????

4??Report??bug??categories?????????
????????????????????????Bug??????????????????
Malicious??code??vulnerability???????????????????????????????????????
Correctness????????????????????????????????????
Internationalization????????????????????????????????????
Performance?????????????????????????????????
Multithreaded??correctness?????????????????????????????????????????????

??????FindBugs???UI?????????????????????????????????????????????Ant??????????????????????????????

??

??

4.???????????? ???Ant?????????FindBugs

Ant???????????????????????????????????????????????????????????????Java???????????????(????????????Maven???????????????)???FindBugs??????????????????Ant????????????Ant Task????????????????????????????????????????????????FindBugs???

???$FINDBUGS_HOME/lib/findbugs-ant.jar?????????$ANT_HOME/lib??????????????????????????????FindBugs???Ant Task????????????(??????????????????FindBugs?????????jar??????)

?????????FindBugs???????????????Ant????????????????????????????????????task???????????????????????????????????????---??????ANT???XML????????????

<taskdef name=???findbugs??? classname=???edu.umd.cs.findbugs.anttask.FindBugsTask??? />

????????????findbugs task??????????????????????????????????????????????????????

<property name="findbugs.home" value="/export/home/daveho/work/findbugs" />??

<target name="findbugs" depends="jar">

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

?????????? output="xml"

?????????? outputFile="bcel-fb.xml" >

<auxClasspath path="${basedir}/lib/Regex.jar" />

<sourcePath path="${basedir}/src/java" />

<class location="${basedir}/bin/bcel.jar" />

</findbugs>

</target>

findbugs???????????????home?????????????????????FindBugs??????????????????

???????????????bcel.jar?????????FindBugs???FindBugs????????????????????????xml??????????????????bcel-fb.xml???????????????????????????jar??????????????????auxClasspath??????????????????BCEL??????????????????

??????????????????:

???https://findbugs.sourceforge.net/downloads.html?????????????????????Findbugs?????????????????????1.3.0,?????2007???11???8????????????????????????????????????????????????lib??????????????????????????????Ant??????????????????FindBugs?????????j2se1.4.0????????????????????????????????????256MB???????????????????????????

???Ant????????????????????????Findbugs????????????????????????????????????

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

????????

??????????<fileset????dir??="${lib.home}/findbugs-1.3.0">??????????

????????

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

????

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

????????

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

????????

????????????Findbugs???????????????????

????????

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

????????

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

????????

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

????????

????????????Findbugs???????????????????

????????

<property??name??="findbugs.home"????value??="${lib.home}/findbugs-1.3.0"/>??????????

????????

<!--??????????findbugs???home???findbugs???task?????????????-->??????????

????????

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

??????

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

????????

excludeFilter="${findbugs_exclude_filter}"????????

????????

????jvmargs="-Xmx384m"????output??="html"??????????????

????????

outputFile??="d:/test.html">??????????

????????????<class??location??="${build.home}/WEB-INF/classes/"/>??????????

??

??????????<!--????????????????findbugs??????????????????????-->??????????

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

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

????<fileset??dir="${build.home}/WEB-INF/lib"??includes="**/*.jar"??/>??????????

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

??????<!--??????????????????????????????????????????????????-->??????????

????????<sourcePath??path??="${src.home}"/>??????????

????<!--??????????????????????????????????????-->??????????

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

????

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

????????

????????????ant??findbugs?????????????

?????????????????????????????????

????????????????????????????????????????????????bug?????????????????????????????????????????????????????????????????????????????????????????????bug?????????????????????????????????????????????????????????????????????????????????????????????bug????????????????????????????????????????????????????????????????????????????????????????????????????????????xml??????????????????xml??????????????????????????????????????????????????

<FindBugsFilter>????????????????????

??????????<!--???????????????????bugcode???HE????????????????-->????????????????????

??????????<Match>????????????????????

??????????????????<BugCode????name??="HE"/>????????????????????

??????????</Match>????????????????????

??????????<!--?????????????????????????bug?????????????-->????????????????????

??????????<Match??class??="com.foobar.AClass"/>????????????????????????

??????????<!--????????????????bugcode???HE????????????????-->??????????????????

??????????<Match??class??="com.foobar.BClass">??????????????????

??????????????????<BugCode????name??="HE"/>??????????????????

??????????</Match>??????????????????

??????????<!--?????????????AMethod???BMethod????????????bugcode???HE????????????????-->??????????????????

??????????<Match??class??="com.foobar.CClass">????????????????????

??????????????????<Or>??????????????????

??????????????????????????<Method??name??="AMethod"/>????????????????????

??????????????????????????<Method??name??="BMethod"/>????????????????????

??????????????????</Or>????????????????????

??????????????????<BugCode??name??="HE"/>????????????????????

??????????</Match>????????????????????

</FindBugsFilter>??????????

????????????????

Findbugs???????????????????????????????????????????????????

<FindBugsFilter>????????????????????

??????????<!--?????????????????????????bug?????????????-->????????????????????

??????????<Match>??????????????????

??????????????<Class??name="com.foobar.MyClass"??/>??????????????????

??????????</Match>????????????????????????

??????????<!--????????????????bugcode???HE????????????????-->????????????????????

??????????<Match??class??="com.foobar.BClass">????????????????????

??????????????????<BugCode????name??="HE"/>????????????????????

??????????</Match>????????????????????

??????????<!--???????????????????????????????????????????bug?????????????-->??????????????????

??????????<Match>??????????????????

??????????????<Class??name="com.foobar.MyClass"/??>??????????????????

??????????????<Bug??code="DE,UrF,SIC"??/>??????????????????

??????????</Match>??????????????????

??????????<!--???????????????????bugcode???HE????????????????-->????????????????????

??????????<Match>????????????????????

??????????????????<BugCode????name??="HE"/>??????????????????

??????????</Match>????????????????????

??????????<!--???????????????????bugcode???DE,UrF,SIC????????????????-->????????????????????

??????????<Match>??????????????????

??????????????<Bug??code="DE,UrF,SIC"??/>??????????????????

??????????</Match>??????????????????

??????????<!--?????????????????????????????????????????????????????????????????-->??????????????????

??????????<Match>??????????????????

??????????????<Bug??category="PERFORMANCE"??/>??????????????????

??????????</Match>??????????????????

??????????<!--???????????????????????????????bugcode???DC????????????????-->????????????????????

??????????<Match>??????????????????

??????????????<Class??name="com.foobar.MyClass"??/>??????????????????

??????????????<Or>??????????????????

??????????????<Method??name="frob"??params="int,java.lang.String"??returns="void"??/>??????????????????

??????????????<Method??name="blat"??params=""??returns="boolean"??/>??????????????????

??????????????</Or>??????????????????

??????????????<Bug??code="DC"??/>??????????????????

??????????</Match>??????????????????

??????????<!--?????????????AMethod???BMethod????????????bugcode???DE,UrF,SIC????????????????-->????????????????????

??????????<Match>??????????????????

????????????????<Class??name="com.foobar.MyClass"??/>??????????????????

??????????????????<Or>????????????????????

??????????????????????????<Method??name??="AMethod"/>????????????????????

??????????????????????????<Method??name??="BMethod"/>????????????????????

??????????????????</Or>????????????????????

??????????????????<BugCode??name??="DE,UrF,SIC??"/>????????????????????

??????????</Match>????????????????????

??????????<!??????????????????????????????bug?????????OS_OPEN_STREAM??????????????-->??????????????????

??????????<Match>??????????????????

??????????????<Class??name="com.foobar.MyClass"??/>??????????????????

??????????????<Method??name="writeDataToFile"??/>??????????????????

??????????????<Bug??pattern="OS_OPEN_STREAM"??/>????????????????

??????????</Match>??????????????????

????????<!??????????????????????????????????????????2???bug??????DLS_DEAD_LOCAL_STORE??????????????-->??????????????????

????????<Match>??????????????????

????????????<Class??name="com.foobar.MyClass"??/>??????????????????

????????????<Method??name="someMethod"??/>??????????????????

????????????<Bug??pattern="DLS_DEAD_LOCAL_STORE"??/>??????????????????

????????????<Priority??value="2"??/>??????????????????

????????</Match>??????????????????

????????<!????????????????????????????????????bugcode???bug????????????????????-->????????????????

????????<!??????????????????????????????bugcode???UUF????????????-->??????????????????

????????<Match>????????????????????

????????????<Class??name="~.*/.Messages"??/>??????????????????

????????????<Bug??code="UUF"??/>????????????????

????????</Match>??????????????????

????????<!????????????????????????bugcode???MS????????????-->??????????????????

????????<Match>??????????????????

????????????<Package??name="~.*/.internal"??/>??????????????????

????????????<Bug??code="MS"??/>??????????????????

????????</Match>??????????????????

????????<!???ui????????????bug?????????SIC_INNER_SHOULD_BE_STATIC_ANON????????????-->??????????????????

????????<Match>??????????????????

????????????<Package??name="~com/.foobar/.fooproject/.ui.*"??/>??????????????????

????????????<Bug??pattern="SIC_INNER_SHOULD_BE_STATIC_ANON"??/>??????????????

????????</Match>??????????????????

????????<!???????????????????????????????????????????????????bugcode???bug??????????????????-->??????????????????

????????<!??????????????????void??main(String[])????????????bug?????????DM_EXIT????????????-->????????????????

????????<Match>??????????????????

????????????<Method??returns="void"??name="main"??params="java.lang.String[]"??/>??????????????????

????????????<Bug??pattern="DM_EXIT"??/>??????????????????

????????</Match>??????????????????

????????<!??????????????????com.foobar.DebugInfo???????????????bugcode???UuF????????????-->??????????????????

????????<Match>??????????????????

????????????<Field??type="com.foobar.DebugInfo"??/>??????????????????

????????????<Bug??code="UuF"??/>??????????????????

????????</Match>??????????????????

</FindBugsFilter>????????

??

??????

??

??

??????findbugs?????????????????????????????????

class

?????? ??????????????????????????????????????????????????????????????????location?????????location??????????????????archive??????(jar,zip???)???????????????class????????????????????????findbugs??????????????????class?????????

auxClasspath

?????? ???????????????????????????????????????????????????????????????????????????????????????????????????????????????

sourcePath

?????? ??????????????????????????????Java?????????????????????

home

?????? ??????????????????findbugs??????????????????

quietErrors

?????? ????????????????????????????????????true????????????????????????????????????????????????????????????????????????false???

reportLevel

?????? ????????????????????????????????????????????????low??????????????????????????????bug????????????medium(?????????)?????????medium???high????????????bug???

output

?????? ????????????????????????????????????

stylesheet

?????? ???????????????????????????html????????????????????????

sort

?????? ??????????????????????????????????????????text?????????????????????????????????????????????class????????????????????????true???

outputFile

?????? ????????????????????????????????????

debug

?????? ??????????????????????????????????????????????????????????????????????????????false???

effort

?????? ???????????????????????????????????????min???default???max???

conserveSpace

?????? ???min effort??????????????????

workHard

?????? ???max effort??????????????????

visitors

?????? ???????????????????????????????????????????????????????????????detectors???

omitVisitors

?????? ?????????????????????detectors?????????visitors?????????????????????????????????????????????detectors???

excludeFilter

?????? ??????????????????????????????Filter???

includeFilter

?????? ??????????????????????????????Filter???

projectFile

?????? ???????????????????????????????????????

jvmargs

?????? ?????????????????????JVM?????????

systemProperty

?????? ???????????????

timeout

?????? ????????????????????????????????????????????????600,000????????????10?????????

failOnError

?????? ????????????????????????????????????FindBugs?????????????????????????????????????????????false???

errorProperty

?????? ??????????????????????????????FindBugs???????????????????????????????????????true???

warningsProperty

?????? ??????????????????????????????FindBugs???????????????????????????????????????true???

build.xml??????

Findbugs???????????????Ant???findbugs?????????????????????????????????????????????build.xml???????????????findbugs???

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

<property name="findbugs.home" value="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 >

???????????????? ???????????????? <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???????????????

????????????????????????:

<project name="findbugsproject" default="findbugs">
<property name="findbugs.home" value="findbugs-1.3.9" />
??<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>??
??<target name="findbugs"> ??????????????????????
???????????? <findbugs home="${findbugs.home}" output="html" outputFile="aaa.html" effort="default">
?????????????????? <class location="Client/classes" />????????????????????????????????????????
?????????????????? <sourcePath path="Client/src" />
???????????? </findbugs>
??</target>??
</project>

?????????Swing??????

???????????? Ant??????????????????????????????????????????Java???????????????????????????build.xml???????????????Ant????????????Findbugs?????????Swing????????????Findbugs??????????????????????????????Findbugs???????????????bin???????????????findbugs.bat?????????

Findbugs???Swing??????????????????????????????

??findbugs-1.3.9.zip??----WINDOWS??????FindBugs??????,???????????????.?????????Ant?????????FindBugs,?????????????????????????????????????????????BAT??????,?????????????????????SWING??????

?????????????????????????????????????????????????????????????????????????????????->??????

???????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????jar??????????????????????????????????????????????????????????????????????????????java?????????????????????????????????????????????????????????????????????????????????????????

?????????????????????????????????????????????????????????

??????????????????

??

????????????????????????????????????????????????????????????Bug???????????????????????????????????????Bugs????????????????????????????????????

??

5.???????????? ??????????????????FindBugs???????????????FindBugs?????????

??????????????????????????????????????????????????????findbugs manual???

6.???????????? FindBugs Bug??????

????????????????????????????????????FindBugs??????????????????????????????Bugs???

??????FindBugs???Bug????????????????????????????????????

https://findbugs.sourceforge.net/bugDescriptions.html

??
????????????????????FindBugs????????????????????????
?????????????????????
?????????????????????????????FindBug?????????????????????????????????????????????????????????????????????????????????
????????????????????hash equals?????????
????????????????????????equals()???hashCode()????????????????????????????????????????????????????????????????????????????????????????????????????????? List???Map???Set?????????????????????????????????????????????????????????????????????????????????????????????????????????
  • ???????????????equals()?????????????????????????????????hashCode????????????????????????????????????
  • ??????????????co-variant?????????equals()???compareTo()??????????????????Bob????????????equals()???????????????equals(Bob)?????????????????????????????????equals()?????????????????Java????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Bob???????????????????????????????????????equals()??????????????????????????????Bob?????????????????????????????????????????????????????????????????????????????????????????????????????????Object.equals()??????????????????????????????Bob??????????????????????????????????????????Bob????????????????????????????????????Object????????????equals()?????????
?????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????String??????????????????????????1??????
????????1.????????????????????????
1?? String aString = "bob";
2?? b.replace('b', 'p');
3?? if(b.equals("pop"))
??
????????????????????????????????2???????????????????????????????????p????????????????????????????????b????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????Null???????????null???????????????dereference??????????????????
???????????????????????????????????????????????????????????????????????????????????null?????????????????????????????????????????null?????????????????????????????????????????????????????????????????null????????????????????????????????????????????????????????????FindBugs?????????????????????????????null???????????????????????null?????????????????????????????????????????2?????????
????????2. Null????????????
1?? Person person = aMap.get("bob");
2?? if (person != null) {
3?????????? person.updateAccessTime();
4?? }
5?? String name = person.getName();
??
????????????????????????????????1??????Map????????????????????????bob??????????????????????????5???????????person??????????????????????????null???????????????????????FindBugs???????????map???????????????bob???????????????????????5????????????????????null???????????????
???????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????3???????????


????????3.?????????????????????????????????????????????
1?? public class Thing {
2?????????? private List actions;
3?????????? public Thing(String startingActions) {
4?????????????????? StringTokenizer tokenizer = new StringTokenizer(startingActions);
5?????????????????? while (tokenizer.hasMoreTokens()) {
6?????????????????????????? actions.add(tokenizer.nextToken());
7?????????????????? }????
8?????????? }
9?? }
??????????????????????????6????????????????????null???????????????????????????actions?????????????????????
????????????????????FindBugs??????????????????????????????????????????????????????????????????????????????????????????????????????FindBugs????????????35???????????????
??????????????FindBugs
???????????FindBugs???????????????????????1.4?????????????????Java Development Kit???JDK??????????????????????????????????????JDK?????????????????????????????????????????????????????????????????????????????FindBugs?????????????????0.7.1???????????????????????????????????????????????????????????????????????????????????????????????zip????????tar?????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????Windows??????????????????????????????????????Unix????????????????????????????????????????????????????????????????????????????????????????????FindBugs?????????????????????????????????????????C:/apps/FindBugs-0.7.3???
?????FindBugs???????????????????????????????????????????????????????????doc???????????????????????????????????????????????????bin?????????????????????FindBugs??????????????????????????????????????????????????????
????????FindBugs
????????????????????????????????????????????????????????????????????FindBugs???????????GUI??????????????????????????Ant???????????Eclipse???????????????????????Maven??????????????????????????GUI????????FindBugs??????????????????????????Ant???????????????????????????????????????????????GUI??????????????????????????????????????????????????????????????????????????????????????????????????UI????????????????????????????????????????????????????????????FindBugs???????????????????????????????????????????????UI????????????????????????
????????FindBugs UI
????????FindBugs UI??????????????????????????????????????????????????1?????????????????FindBugs UI???????????????????????????????????????????????????????????????????????1???????????????Naked notify in method??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Source code?????????????????????????????????????????FindBugs????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????FinBugs????????Ant???????????????????????????????????FindBugs????????????xml??????ouput?????????????????????????????????????????????????????UI?????????????????????????????????????????????????????????????UI??????????????????????????????????????????
?????FindBugs????????Ant????????????
?????????????????????????????Ant???????????????????????FindBugs??????????????FindBugs Ant?????????????????Ant?????lib????????????????????Ant?????????????????????????????FIND_BUGS_HOME/lib/FindBugs-ant.jar???????????ANT_HOME/lib???
???????????????????????????????????????????????????????????FindBugs?????????????????FindBugs??????????????????????????????????????????taskdef??????????????Ant???????????????????????????????????????????????????????????????????????????????????????
<taskdef name="FindBugs" classname="edu.umd.cs.FindBugs.anttask.FindBugsTask"/>
??
????????????taskdef???????????????????????????FindBugs????????????????????????????????????????????????????????????????????????????????4???????????


????????4.????????FindBugs??????
1?? <target name="FindBugs" depends="compile">
2?????????? <FindBugs home="${FindBugs.home}" output="xml" outputFile="jedit-output.xml">
3?????????????????? <class location="c:/apps/JEdit4.1/jedit.jar" />
4?????????????????? <auxClasspath path="${basedir}/lib/Regex.jar" />
5?????????????????? <sourcePath path="c:/tempcbg/jedit" />
6?????????? </FindBugs>
7?? </target>
??
???????????????????????????????????????????????????????????????
?????1????????????target????????????????????????????????????????????????????????????????????????????????????target????????????????????????????????FindBugs?????????????????????????????????FindBugs????????????????????????????????????????????????????????????JAR??????????????????????????????
?????2??????????????????????????FindBugs???????????????????????Ant???????????????????????????????????????
<property name="FindBugs.home" value="C:/apps/FindBugs-0.7.3" />
??
????????????output????????FindBugs????????????????????????????????????????????????xml???text??????emacs?????????????????????outputFile?????????FindBugs?????????????????????????????????????????XML????????????????????UI???????????????????????????
?????3??????class???????????????????????FindBugs??????????????JAR?????????????????????????????????????????JAR???????????????????????????????????????????????????????????????class????????????????????????projectFile?????????????????????class????????????????????????????????FindBugs???????????
?????4?????????????????????auxClasspath?????????????????????????????????????????????????????????????????????????????FindBugs?????????????????????????????????????????????????????????????????????????FindBugs?????????????????????????????????????????????????????????????????????????????????????????????class??????????????????????????FindBugs?????????????????????auxClasspath?????????auxClasspath?????????????????????
?????5?????????????????????sourcePath???????????????path????????????????????????????????????????????????????????????????????????????????FindBugs?????????????GUI???????????XML?????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????
?????????
??????????????FindBugs?????????????????????????????????????????????????????????/???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????JEdit???????????

最後更新:2017-04-03 12:55:46

  上一篇:go 積累(一)
  下一篇:go Android開源庫loopj的android-async-http的 JsonHttpResponseHandler 存在死循環GC_CONCURRENT