- 浏览: 1486009 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (595)
- Java咖啡厅 (208)
- IT杂侃 (23)
- 程序员笑话 (7)
- 我的后现代文学 (1)
- WEB编程 (116)
- 软件评测 (8)
- 操作系统 (3)
- 炫目Ruby (2)
- 行业知识 (7)
- 我的动漫情结 (6)
- 其他 (8)
- Window DIY (6)
- 古文学 (3)
- 转载文章 (2)
- IT百科 (7)
- 动态网页Active (1)
- 文档 (1)
- 设计理论 (11)
- .NET 快速开发 (18)
- 英语学习 (6)
- 网站分析 (2)
- 开源软件 (4)
- 数据库 (28)
- 笔记 (4)
- 源代码共享 (8)
- IT人物 (2)
- 软件管理 (10)
- 小说创作 (0)
- 大众软件 (12)
- 网站评论 (3)
- 小虾乱说 (10)
- 游戏 (8)
- 心情 (3)
- 娱乐休闲 (2)
- Delphi编程 (1)
- PHP编程 (4)
- 中间件 (2)
- 移动开发 (2)
- Office应用 (2)
- Photoshop (1)
- Eclipse (5)
- 面试题 (1)
- 手机评测 (0)
- VBScript (1)
- WEB前端-EXT (3)
- 吐槽 (1)
- Java咖啡厅 Ibatis (1)
- javascript Ext (1)
- jquery ui (1)
- require (1)
- WEB编程 Javascript (1)
- jquery (1)
- Swing (1)
- 分布式 (1)
最新评论
-
zhangjihao:
28. 下面哪个Set是排序的? A. LinkedHas ...
Java面试题(选择题) -
zhangthe9:
ICMP报文被封装在IP包里,也就是说他是由IP协议承载的,从 ...
Java面试题(选择题) -
zhunengfei:
真的假的?
自已写的jquery ui框架 -
white_crucifix:
少年,发烫是所有智能手机的特点,而莫名发烫是所有安卓手机的特点 ...
【吐槽】三星手机的OS是一砣屎 -
suzu88:
试了一下,可以用。如果美化一下控件和窗体更有意思。
一个用XML构建Swing视图的框架
Findbugs是一个Java项目的静态分析工具
CruiseControl很好的支持了Findbugs的集成。
本文主要讲述如何将Findbugs集成了CruiseControl之中。
第一步:增加Findbugs到Build文件中
在Ant的Build文件中,增加:
<findbugs home="${findbugs.home}"
output="xml:withMessages"
outputFile="findbugs/${projectname}-fb.xml">
.
.
.
</findbugs>
第二步:增加CruiseControl的日志文件指向
在CruiseControl的Config.xml文件中增加
<merge dir="${builddir}/findbugs" pattern="*-fb.xml"/>
到<log>标签
第三步:增加cruisecontrol.css的内容
找到{CruiseControl安装目录}\webapps\cruisecontrol\css文件夹下的cruisecontrol.css文件中,在文件的末尾加上:
.findbugs-oddrow { background-color:#CCCCCC }
.findbugs-data { font-family:arial,helvetica,sans-serif; font-size:8pt; color:#000000; }
.findbugs-sectionheader { background-color:#000066; font-family:arial,helvetica,sans-serif; font-size:10pt; color:#FFFFFF; }
.findbugs-tablerow0 { font-family:arial,helvetica,sans-serif; font-size:8pt; color:#000000; background-color: #FFFFFF; }
.findbugs-tablerow1 { font-family:arial,helvetica,sans-serif; font-size:8pt; color:#000000; background-color:#CCCCCC; }
.findbugs-detailrow0 { font-family:arial,helvetica,sans-serif; font-size:8pt; color:#000000; background-color: #FFFFFF; }
.findbugs-detailrow1 { font-family:arial,helvetica,sans-serif; font-size:8pt; color:#000000; background-color:#CCCCCC; }
.findbugs-tableheader { font-family:arial,helvetica,sans-serif; font-size:9pt; font-weight: bold; color:#000080; background-color:#CCDDDD; }
.findbugs-warningtable tr.findbugs-tablerow0:hover, .findbugs-warningtable tr.findbugs-tablerow1:hover { background-color: #aaffaa; }
.findbugs-priority-1 { color: red; font-weight: bold; }
.findbugs-priority-2 { color: orange; font-weight: bold; }
.findbugs-priority-3 { color: green; font-weight: bold; }
.findbugs-priority-4 { color: blue; font-weight: bold;}
第四步:在CruiseControl的主界面上增加一个新的Tab。
找到{CruiseControl安装目录}\webapps\cruisecontrol文件夹下的main.jsp文件中,在文件加上:
<cruisecontrol:tab name="findbugs" label="FindBugs" >
<%@ include file="findbugs.jsp" %>
</cruisecontrol:tab>
第五步:增加findbugs.jsp
增加到{CruiseControl安装目录}\webapps\cruisecontrol中,
内容为:
<%@ taglib uri="/WEB-INF/cruisecontrol-jsp11.tld" prefix="cruisecontrol"%>
<cruisecontrol:xsl xslFile="/xsl/findbugs-details.xsl"/>
第六步:增加 findbugs-details.xsl
增加到 {CruiseControl安装目录}\webapps\cruisecontrol\xsl 中,
内容为:
<?xml version="1.0" encoding="UTF-8"?>
<!--
FindBugs - Find bugs in Java programs
Copyright (C) 2004,2005 University of Maryland
Copyright (C) 2005, Chris Nappin
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<!--
A simple XSLT stylesheet to transform FindBugs XML results
annotated with messages into HTML.
If you want to experiment with modifying this stylesheet,
or write your own, you need to generate XML output from FindBugs
using a special option which lets it know to include
human-readable messages in the XML. Invoke the findbugs script
as follows:
findbugs -textui -xml:withMessages -project myProject.fb > results.xml
Then you can use your favorite XSLT implementation to transform
the XML output into HTML. (But don't use xsltproc. It generates well-nigh
unreadable output, and generates incorrect output for the
<script> element.)
Authors:
David Hovemeyer
Chris Nappin (summary table)
Nicholas Cull (adapted for CruiseControl)
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:apply-templates select="." mode="findbugs"/>
</xsl:template>
<xsl:template match="/" mode="findbugs">
<xsl:variable name="unique-catkey" select="/cruisecontrol/BugCollection/BugCategory/@category"/>
<script type="text/javascript">
function toggleRow(elid) {
if (document.getElementById) {
element = document.getElementById(elid);
if (element) {
if (element.style.display == 'none') {
element.style.display = 'block';
//window.status = 'Toggle on!';
} else {
element.style.display = 'none';
//window.status = 'Toggle off!';
}
}
}
}
</script>
<xsl:if test="count(cruisecontrol/BugCollection) = 0">
FindBugs was not run against this project.
</xsl:if>
<xsl:if test="count(cruisecontrol/BugCollection) > 0">
<table class="header" align="center" border="0" cellpadding="8" cellspacing="0" width="98%">
<tr>
<th class="big">FindBugs Report</th>
</tr>
</table>
<table align="center" cellpadding="8" cellspacing="0" border="0" width="98%">
<tr>
<td class="findbugs-sectionheader">Metrics</td>
</tr>
<xsl:apply-templates select="/cruisecontrol/BugCollection/FindBugsSummary" mode="findbugs"/>
<tr>
<td> </td>
</tr>
<tr>
<td class="findbugs-sectionheader">Summary</td>
</tr>
<tr>
<td>
<table width="500" cellpadding="5" cellspacing="2">
<tr class="findbugs-tableheader">
<th align="left">Warning Type</th>
<th align="right">Number</th>
</tr>
<xsl:for-each select="$unique-catkey">
<xsl:sort select="." order="ascending"/>
<xsl:variable name="catkey" select="."/>
<xsl:variable name="catdesc" select="/cruisecontrol/BugCollection/BugCategory[@category=$catkey]/Description"/>
<xsl:variable name="styleclass">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">findbugs-tablerow0</xsl:when>
<xsl:otherwise>findbugs-tablerow1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$styleclass}">
<td><xsl:value-of select="$catdesc"/> Warnings</td>
<td align="right"><xsl:value-of select="count(/cruisecontrol/BugCollection/BugInstance[@category=$catkey])"/></td>
</tr>
</xsl:for-each>
<xsl:variable name="styleclass">
<xsl:choose>
<xsl:when test="count($unique-catkey) mod 2 = 0">findbugs-tablerow0</xsl:when>
<xsl:otherwise>findbugs-tablerow1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$styleclass}">
<td><b>Total</b></td>
<td align="right"><b><xsl:value-of select="count(/cruisecontrol/BugCollection/BugInstance)"/></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="findbugs-sectionheader">Warnings</td>
</tr>
<tr class="findbugs-tablerow0">
<td>Click on a warning row to see full context information.</td>
</tr>
<tr>
<td>
<table align="center" cellpadding="8" cellspacing="0" border="0" width="98%">
<xsl:for-each select="$unique-catkey">
<xsl:sort select="." order="ascending"/>
<xsl:variable name="catkey" select="."/>
<xsl:variable name="catdesc" select="/cruisecontrol/BugCollection/BugCategory[@category=$catkey]/Description"/>
<xsl:call-template name="generateWarningTable">
<xsl:with-param name="warningSet" select="/cruisecontrol/BugCollection/BugInstance[@category=$catkey]"/>
<xsl:with-param name="sectionTitle"><xsl:value-of select="$catdesc"/> Warnings</xsl:with-param>
<xsl:with-param name="sectionId">Warnings_<xsl:value-of select="$catkey"/></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="findbugs-sectionheader"><a name="Details">Details</a></td>
</tr>
<xsl:apply-templates select="/cruisecontrol/BugCollection/BugPattern" mode="findbugs">
<xsl:sort select="@abbrev"/>
<xsl:sort select="ShortDescription"/>
</xsl:apply-templates>
<tr>
<td> </td>
</tr>
</table>
</xsl:if>
</xsl:template>
<xsl:template match="BugInstance" mode="findbugs">
<xsl:variable name="warningId"><xsl:value-of select="generate-id()"/></xsl:variable>
<tr class="findbugs-tablerow{position() mod 2}" onclick="toggleRow('{$warningId}');">
<td>
<span>
<xsl:attribute name="class">findbugs-priority-<xsl:value-of select="@priority"/></xsl:attribute>
<xsl:value-of select="@abbrev"/>
</span>
</td>
<td>
<xsl:value-of select="LongMessage"/>
</td>
</tr>
<!-- Add bug annotation elements: Class, Method, Field, SourceLine, Field -->
<tr class="findbugs-detailrow{position() mod 2}">
<td/>
<td>
<p id="{$warningId}" style="display: none;">
Bug type <xsl:value-of select="@type"/>
<xsl:for-each select="./*/Message">
<br/><xsl:value-of select="text()" disable-output-escaping="no"/>
</xsl:for-each>
</p>
</td>
</tr>
</xsl:template>
<xsl:template match="BugPattern" mode="findbugs">
<tr>
<td>
<table width="100%" cellspacing="0">
<tr class="findbugs-tableheader">
<td><a name="{@type}"><xsl:value-of select="@type"/>: <xsl:value-of select="ShortDescription"/></a></td>
</tr>
<tr>
<td class="findbugs-tablerow0">
<xsl:value-of select="Details" disable-output-escaping="yes"/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template name="generateWarningTable">
<xsl:param name="warningSet"/>
<xsl:param name="sectionTitle"/>
<xsl:param name="sectionId"/>
<tr>
<td class="findbugs-sectionheader">
<a name="{$sectionId}"><xsl:value-of select="$sectionTitle"/></a>
</td>
</tr>
<tr>
<td>
<table class="findbugs-warningtable" width="100%" cellspacing="0">
<tr class="findbugs-tableheader">
<th align="left">Code </th>
<th align="left">Warning</th>
</tr>
<xsl:apply-templates select="$warningSet" mode="findbugs">
<xsl:sort select="@abbrev"/>
<xsl:sort select="Class/@classname"/>
</xsl:apply-templates>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="FindBugsSummary" mode="findbugs">
<xsl:variable name="kloc" select="@total_size div 1000.0"/>
<xsl:variable name="format" select="'#######0.00'"/>
<tr class="findbugs-tablerow0">
<td>
<xsl:value-of select="@total_size"/> lines of code analysed,
in <xsl:value-of select="@total_classes"/> classes,
in <xsl:value-of select="@num_packages"/> packages.
</td>
</tr>
<tr>
<td>
<table width="500" cellpadding="5" cellspacing="2">
<tr class="findbugs-tableheader">
<th align="left">Metric</th>
<th align="right">Total</th>
<th align="right">Density*</th>
</tr>
<tr class="findbugs-tablerow0">
<td>High Priority Warnings</td>
<td align="right"><xsl:value-of select="@priority_1"/></td>
<td align="right"><xsl:value-of select="format-number(@priority_1 div $kloc, $format)"/></td>
</tr>
<tr class="findbugs-tablerow1">
<td>Medium Priority Warnings</td>
<td align="right"><xsl:value-of select="@priority_2"/></td>
<td align="right"><xsl:value-of select="format-number(@priority_2 div $kloc, $format)"/></td>
</tr>
<xsl:if test="@priority_3">
<tr class="findbugs-tablerow0">
<td>Low Priority Warnings</td>
<td align="right"><xsl:value-of select="@priority_3"/></td>
<td align="right"><xsl:value-of select="format-number(@priority_3 div $kloc, $format)"/></td>
</tr>
</xsl:if>
<xsl:variable name="totalClass">
<xsl:choose>
<xsl:when test="@priority_3"><xsl:text>findbugs-tablerow1</xsl:text></xsl:when>
<xsl:otherwise><xsl:text>findbugs-tablerow0</xsl:text></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$totalClass}">
<td><b>Total Warnings</b></td>
<td align="right"><b><xsl:value-of select="@total_bugs"/></b></td>
<td align="right"><b><xsl:value-of select="format-number(@total_bugs div $kloc, $format)"/></b></td>
</tr>
</table>
</td>
</tr>
<tr class="findbugs-tablerow0">
<td><i>(* Defects per Thousand lines of non-commenting source statements)</i></td>
</tr>
</xsl:template>
</xsl:stylesheet>
第七步:增加 buildresults.xsl 的内容
.
.
.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="maven.xsl"/>
<xsl:import href="nant.xsl"/>
<xsl:import href="checkstyle.xsl"/>
<xsl:import href="pmd.xsl"/>
<xsl:import href="findbugs.xsl"/>
.
.
.
<xsl:template match="/">
<p><xsl:apply-templates select="$cruisecontrol.list" mode="maven"/></p>
<p><xsl:apply-templates select="$cruisecontrol.list" mode="nant"/></p>
<p><xsl:apply-templates select="$cruisecontrol.list" mode="checkstyle"/></p>
<p><xsl:apply-templates select="$cruisecontrol.list" mode="pmd"/></p>
<p><xsl:apply-templates select="$cruisecontrol.list" mode="findbugs"/></p>
.
.
第八步:增加 findbugs.xsl 文件
内容为:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<!-- Any FindBugs error with a priority below this threshold are considered
warnings and not errors
-->
<xsl:param name="findbugs.warning.threshold" select="3"/>
<xsl:template match="/" mode="findbugs">
<xsl:apply-templates select="/cruisecontrol/BugCollection" mode="findbugs"/>
</xsl:template>
<xsl:template match="BugCollection" mode="findbugs">
<xsl:variable name="total.error.count" select="count(BugInstance[@priority < $findbugs.warning.threshold])" />
<xsl:variable name="total.warning.count" select="count(BugInstance)" />
<table align="center" cellpadding="2" cellspacing="0" border="0" width="98%">
<colgroup>
<col width="45%"></col>
<col width="5%"></col>
<col width="50%"></col>
</colgroup>
<tr>
<td class="findbugs-sectionheader" colspan="3">
FindBugs errors/warnings (<xsl:value-of select="$total.error.count"/>
/ <xsl:value-of select="$total.warning.count"/>)
</td>
</tr>
<xsl:for-each select="BugInstance">
<tr>
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">findbugs-oddrow</xsl:attribute>
</xsl:if>
<td class="findbugs-data"><xsl:value-of select="Class/@classname" /></td>
<td class="findbugs-data" align="right"><xsl:value-of select="SourceLine[1]/@start" /></td>
<td class="findbugs-data"><xsl:value-of select="ShortMessage/text()" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="*" mode="findbugs"/>
<xsl:template match="/">
<xsl:apply-templates select="." mode="findbugs"/>
</xsl:template>
</xsl:stylesheet>
第九步:增加 metrics.jsp 的内容
.
.
<jsp:useBean id="xpathData" class="net.sourceforge.cruisecontrol.chart.XPathChartData" />
<%
xpathData.add("CheckStyle", "count(/cruisecontrol/checkstyle/file/error)");
xpathData.add("FindBugs", "count(/cruisecontrol/BugCollection/BugInstance)");
xpathData.add("PMD", "count(/cruisecontrol/pmd/file/violation)");
xpathData.add("Javadoc", "count(/cruisecontrol/build//target/task[@name='javadoc'])");
%>
.
.
.
效果图见附件
发表评论
-
建立SVN的Window服务
2011-06-01 19:14 2217简单的说,要让它执行起来,需要作如下事情: 理所当然 ... -
SVN在Linux上的安装方法
2010-12-05 09:39 1127SVN简介、下载、安装 SVN简介 The goal of ... -
SVN中文文档
2010-08-30 22:16 2745使用Subversion进行版本控 ... -
安装SVN 1.6
2010-04-29 21:15 3121svn-win32-1.6.1.zip(http://subv ... -
fortify SCA 代码检测工具
2010-03-07 08:59 16153Fortify Source Code Analysis Su ... -
Findbugs安装使用文档
2010-03-01 00:14 39040一、简介 Findbugs 是一个静态分析 ... -
测试的基本理论与方法
2010-02-25 22:59 1922这些文字是公司一次培训所用的PP资料,觉得讲得很有道理,真正好 ... -
CruiseControl安装手册
2010-01-10 18:57 4658CruiseControl简介: Cruis ... -
CruiseControl使用指南
2009-10-15 23:58 4317我使用的CruiseControl版本为2.8.2,这个版本是 ...
相关推荐
Jenkins 与findbugs集成 Jenkins 与findbugs集成,超详细
ant编译后用findBugs扫描代码的硬伤,让你知道自己的的代码哪来不行。。
findbugs 1.3.9 findbugs 1.3.9 findbugs 1.3.9 findbugs 1.3.9 findbugs 1.3.9 findbugs 1.3.9
FindBugs 是一个使用静态分析来 ** 查找 Java 代码中的错误 ** 的程序。它是免费软件 当前版本的 FindBugs 是 3.0.1 FindBugs 运行需要 1.7 或更高版本的 JRE(或 JDK)
SonarQube的FindBugs插件sonar-findbugs-plugin.jar(版本:4.0.1-SNAPSHOT),包含FindBugs Security Audit等规则,可以离线集成到sonarqube。
Eclipse集成findBugs步骤,包含:FindBugs介绍,在Eclipse中安装FindBugs插件,在Eclipse中使用FindBugs,配置FindBugs,其它分析工具(PMD,CheckStyle),配套的Bug解释模式,实际项目中Bug类型统计
资源讲述了如何安装下载配置findbugs以及如何将hudson集成findbugs插件
插件安装时,我们只需在eclipse根目录下新建一个【links】目录,然后在里面创建【.link】扩展名的文件,在里面写上类似于【path=F:\\IDE\\eclipsePlugin\\findbugs\\findbugs1.3.4】这样的配置信息,不就可以统一...
FindBugs提供了集成在Ant中使用的Ant Task,可以在自动构建与部署的时候运行FindBugs。 1. 将$FINDBUGS_HOME/lib/findbugs-ant.jar拷贝到$ANT_HOME/lib目录下以后,就完成了FindBugs的Ant Task的安装。(强烈建议使用...
myeclipse 和 eclipse 集成插件
FindBugs 是由马里兰大学提供的一款开源 Java静态代码分析工具。FindBugs通过检查类文件或 JAR文件,将字节码与一组缺陷模式进行对比从而发现代码缺陷,完成静态代码分析。FindBugs既提供可视化 UI 界面,同时...
Eclipse集成findBugs步骤.pdf
jenkins持续集成单元测试和findbugs问题解决方案 1.如何集成单元测试 2.如何集成findbugs 3.tomcat热部署问题解决例如: jar包无法删除和log4j问题
赠送jar包:findbugs-annotations-1.3.9-1.jar; 赠送原API文档:findbugs-annotations-1.3.9-1-javadoc.jar; 赠送源代码:findbugs-annotations-1.3.9-1-sources.jar; 赠送Maven依赖信息文件:findbugs-...
1. 将该文件夹拷贝到myeclipse安装目录下common/plugins目录下; 2. 修改myeclipse目录下..\MyEclipse\MyEclipse 10\configuration\org.eclipse.equinox.simpleconfigurator的bundles.info文件
在这个由两部分组成的系列文章的第一部分中,高级软件工程师 Chris Grindstaff 分析了 FindBugs 如何帮助提高代码质量以及排除隐含的缺陷。代码质量工具的一个问题是它们容易为开发人员提供大量但并非真正问题的问题...
Eclipse集成findBugs,一款很好用的查找BUG的插件,希望对大家有所帮助,提高代码质量!
Findbugs代码检查工具使用说明,具体操作步骤
findbugs.jar开发findbugs自定义插件
用于findbugs安装配置,及findbugs结果导出分析文档