Findbugs ant code review tool

Source: Internet
Author: User
Findbugs ant code review tool
    Blog type:

  • Every day
Findbugsantcodeauditfindbugs_exclude

 

FindbugsIs a static analysis tool that checks the class or jar files and compares bytecode with a set of defect modes to find possible problems. With this tool, you can analyze the software without actually running the program. It can help improve the quality of code.

FindbugsIt provides a convenient visual interface and can also be used as a plug-in of eclipse. We use the most plug-in as Eclipse.

Docheck. bat

------------

@ Ant-F fingbugs. xml

---------

Fingbugs. xml

---------------------------------

 

<Project name = "sharedtargetsmacros" default = "findbugs">

<! -- Define shared properties -->

<Property name = "project. Path" value = "D:/projectaddr"/>

<Property name = "auditcode. Path" value = "$ {project. Path}/classes/COM/omitted this time"/>

<! -- <Property name = "findbugs. Home" value = "C:/programing/Java/findbugs-1.3.9"/> -->

<Property name = "findbugs. Home" value = "E:/apps/findbugs-1.3.9"/>

<Property name = "Lib. Path" value = "$ {project. Path}/WEB-INF/lib"/>

<! -- Define path references -->

<Path id = "findbugs. classpath">

<Fileset dir = "$ {findbugs. Home}/lib" Using DES = "*. Jar"/>

</Path>

<Target name = "metrics" depends = "findbugs"/>

<Target name = "findbugs">

<Taskdef name = "findbugs" classname = "edu. UMD. cs. findbugs. anttask. findbugstask" classpathref = "findbugs. classpath"/>

<Findbugs projectname = "projectname" home = "$ {findbugs. Home }"
Output = "html" outputfile = "projectname.html" jvmargs = "-xmx256m-xmx256m" reportlevel = "low" excludefilter = "findbugs_exclude.xml"> <! -- Filter files -->

<Auxclasspath Path = "classes"/>

<! --

<Auxclasspath Path = "$ {Lib. Path}/*. Jar"/>

<Auxclasspath Path = "$ {Lib. Path}/test/*. Jar"/>

<Auxclasspath Path = "$ {Lib. Path}/wseeclient/*. Jar"/>

-->


<Auxclasspath Path = "$ {Lib. Path}/struts. Jar"/>

<Auxclasspath Path = "$ {Lib. Path}/jcs-1.3.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/poi-2.5.1-final-20040804.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/javax. ejb_3.0.1.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/javax. jsp_1.1.0.0_2-1.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/json-lib-2.2.2-jdk15.jar"/>


<Auxclasspath Path = "$ {Lib. Path}/commons-lang.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/commons-httpclient-2.0.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/weblogic. Jar"/>


<Auxclasspath Path = "$ {Lib. Path}/quartz-all-1.6.0.jar"/>

<Auxclasspath Path = "$ {Lib. Path}/jaxb1-impl-2.2.jar"/>


<Auxclasspath Path = "$ {Lib. Path}/junit-4.8.1.jar"/>

<Class location = "$ {auditcode. Path}/Action/*. Class"
/>

<Class location = "$ {auditcode. Path}/bean/*. Class"
/>

<Class location = "$ {auditcode. Path}/Delegate/*. Class"
/>

<Class location = "$ {auditcode. Path}/form/*. Class"
/>

<Class location = "$ {auditcode. Path}/helper/*. Class"
/>

<Class location = "$ {auditcode. Path}/helper/AP/*. Class"
/>

<Sourcepath Path = "$ {Lib. Path}/trunk/src/COM/omitted here/**/*. Java"/>

</Findbugs>

</Target>

</Project>

-------------------

Filter files

The findbugs_exclude.xml content is as follows:

<Findbugsfilter>
<Match>
<Method name = "Main"/>
</Match>
<Match>
<Class name = "~. * \. * Test "/>
</Match>
<Match>
<Class name = "~. * \. * Value "/>
</Match>
<Match>
<Class name = "~. * \. * Value \ $. * "/>
</Match>
<Match>
<Class name = "~. * \. * Table "/>
</Match>
</Findbugsfilter>
This filters out classes such as value, table, and cache.

<project name='annogen.findbugs' default='all.clean' basedir='.'>  <!-- Properties -->  <property environment='env'/>  <property name='output_dir'        location='build/findbugs'/>  <property name='output_file'       location='${output_dir}/index.html'/>  <property name='findbugs_home'     location='external/findbugs'/>  <property name='findbugs_jar'      location='${findbugs_home}/lib/findbugs-ant.jar'/>  <property name='stax_api_jar'      location='external/lib/stax-api.jar'/>  <property name='junit_jar'         location='external/lib/junit.jar' />  <path id='sourcepath'>    <dirset dir='.'>      <include name='**/src/'/>      <include name='**/src_150'/>    </dirset>  </path>  <!-- Targets -->  <target name='all.clean' depends='clean,all'/>  <target name='clean'>    <delete dir='${output_dir}'/>  </target>  <target name='all'>    <mkdir dir='${output_dir}'/>    <taskdef name='findbugs'             classname='edu.umd.cs.findbugs.anttask.FindBugsTask'             classpath='${findbugs_jar}'/>    <findbugs home='${findbugs_home}'              output='html'              outputFile='${output_file}' >      <auxClasspath path='${stax_api_jar};${env.ANT_HOME}/lib/ant.jar;${junit_jar}' />      <sourcePath refid='sourcepath' />      <class location='build/classes'/>    </findbugs>    <echo message=''/>    <echo message='Findbugs complete, output in ${output_file}'/>  </target>  <target name='view' depends='all.clean'>    <exec dir='.' executable='explorer.exe' os='Windows 2000, Windows XP'>      <!--<arg line="X:\metajam\jam\annogen_new\build\findbugs\index.html"/>-->      <arg line='${output_file}'/>    </exec>  </target></project>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.