|
Line 0
Link Here
|
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
|
| 3 |
<!-- |
| 4 |
FindBugs - Find bugs in Java programs |
| 5 |
Copyright (C) 2004,2005 University of Maryland |
| 6 |
|
| 7 |
This library is free software; you can redistribute it and/or |
| 8 |
modify it under the terms of the GNU Lesser General Public |
| 9 |
License as published by the Free Software Foundation; either |
| 10 |
version 2.1 of the License, or (at your option) any later version. |
| 11 |
|
| 12 |
This library is distributed in the hope that it will be useful, |
| 13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
Lesser General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU Lesser General Public |
| 18 |
License along with this library; if not, write to the Free Software |
| 19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
--> |
| 21 |
|
| 22 |
<!-- |
| 23 |
- $Header$ |
| 24 |
- |
| 25 |
- XSL template for FindBugs results reporting inside of CruiseControl. |
| 26 |
- |
| 27 |
- Copyright (C) 2005 Christopher G. Stach II <cgs@ldsys.net> |
| 28 |
- |
| 29 |
- This program is free software; you can redistribute it and/or |
| 30 |
- modify it under the terms of the GNU General Public License |
| 31 |
- as published by the Free Software Foundation; either version 2 |
| 32 |
- of the License, or (at your option) any later version. |
| 33 |
- |
| 34 |
- This program is distributed in the hope that it will be useful, |
| 35 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 36 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 37 |
- GNU General Public License for more details. |
| 38 |
- |
| 39 |
- You should have received a copy of the GNU General Public License |
| 40 |
- along with this program; if not, write to the Free Software |
| 41 |
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 42 |
- |
| 43 |
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 44 |
- This was modified from the original src/xsl/default.xsl distributed with |
| 45 |
- FindBugs 0.8.8 to work with CruiseControl 2.2.1. |
| 46 |
- |
| 47 |
- * Made it work. |
| 48 |
- * Improved appearance so it would not look like crap on the build report |
| 49 |
- page. |
| 50 |
- * Added [better] Class, Method, Field, and SourceLine support. |
| 51 |
- * Use CSS for more stuff. |
| 52 |
--> |
| 53 |
|
| 54 |
<!-- |
| 55 |
A simple XSLT stylesheet to transform FindBugs XML results |
| 56 |
annotated with messages into HTML. |
| 57 |
|
| 58 |
If you want to experiment with modifying this stylesheet, |
| 59 |
or write your own, you need to generate XML output from FindBugs |
| 60 |
using a special option which lets it know to include |
| 61 |
human-readable messages in the XML. Invoke the findbugs script |
| 62 |
as follows: |
| 63 |
|
| 64 |
findbugs -textui -xml:withMessages -project myProject.fb > results.xml |
| 65 |
|
| 66 |
Then you can use your favorite XSLT implementation to transform |
| 67 |
the XML output into HTML. (But don't use xsltproc. It generates well-nigh |
| 68 |
unreadable output, and generates incorrect output for the |
| 69 |
<script> element.) |
| 70 |
|
| 71 |
Authors: |
| 72 |
David Hovemeyer |
| 73 |
--> |
| 74 |
|
| 75 |
<xsl:stylesheet |
| 76 |
version="1.0" |
| 77 |
xmlns="http://www.w3.org/1999/xhtml" |
| 78 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 79 |
|
| 80 |
<xsl:output method="html" /> |
| 81 |
|
| 82 |
<xsl:variable name="literalNbsp">&nbsp;</xsl:variable> |
| 83 |
|
| 84 |
<xsl:variable name="bugTableHeader"> |
| 85 |
<tr class="findbugs-tableheader"> |
| 86 |
<th align="left">Code<xsl:value-of select="$literalNbsp" disable-output-escaping="yes"/></th> |
| 87 |
<th align="left">Warning</th> |
| 88 |
</tr> |
| 89 |
</xsl:variable> |
| 90 |
|
| 91 |
<xsl:template match="/" mode="findbugs"> |
| 92 |
<xsl:apply-templates select="cruisecontrol/BugCollection" mode="findbugs" /> |
| 93 |
</xsl:template> |
| 94 |
|
| 95 |
<xsl:template match="BugCollection[*]" mode="findbugs"> |
| 96 |
<script type="text/javascript"> |
| 97 |
function toggleRow(elid) { |
| 98 |
if (document.getElementById) { |
| 99 |
element = document.getElementById(elid); |
| 100 |
if (element) { |
| 101 |
if (element.style.display == 'none') { |
| 102 |
element.style.display = 'block'; |
| 103 |
//window.status = 'Toggle on!'; |
| 104 |
} else { |
| 105 |
element.style.display = 'none'; |
| 106 |
//window.status = 'Toggle off!'; |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
} |
| 111 |
</script> |
| 112 |
<table align="center" cellpadding="2" cellspacing="0" border="0" width="98%"> |
| 113 |
<tr> |
| 114 |
<td class="findbugs-sectionheader">FindBugs violations (<xsl:value-of select="count(BugInstance)" />)</td> |
| 115 |
</tr> |
| 116 |
<tr> |
| 117 |
<td class="findbugs-data"> |
| 118 |
<xsl:apply-templates select="Project" mode="findbugs" /> |
| 119 |
|
| 120 |
<xsl:call-template name="generateWarningTable"> |
| 121 |
<xsl:with-param name="warningSet" select="BugInstance[@category='CORRECTNESS']"/> |
| 122 |
<xsl:with-param name="sectionTitle">Correctness Warnings</xsl:with-param> |
| 123 |
<xsl:with-param name="sectionId">Warnings_CORRECTNESS</xsl:with-param> |
| 124 |
</xsl:call-template> |
| 125 |
|
| 126 |
<xsl:call-template name="generateWarningTable"> |
| 127 |
<xsl:with-param name="warningSet" select="BugInstance[@category='I18N']"/> |
| 128 |
<xsl:with-param name="sectionTitle">Internationalization Warnings</xsl:with-param> |
| 129 |
<xsl:with-param name="sectionId">Warnings_I18N</xsl:with-param> |
| 130 |
</xsl:call-template> |
| 131 |
|
| 132 |
<xsl:call-template name="generateWarningTable"> |
| 133 |
<xsl:with-param name="warningSet" select="BugInstance[@category='MT_CORRECTNESS']"/> |
| 134 |
<xsl:with-param name="sectionTitle">Multithreaded Correctness Warnings</xsl:with-param> |
| 135 |
<xsl:with-param name="sectionId">Warnings_MT_CORRECTNESS</xsl:with-param> |
| 136 |
</xsl:call-template> |
| 137 |
|
| 138 |
<xsl:call-template name="generateWarningTable"> |
| 139 |
<xsl:with-param name="warningSet" select="BugInstance[@category='MALICIOUS_CODE']"/> |
| 140 |
<xsl:with-param name="sectionTitle">Malicious Code Vulnerability Warnings</xsl:with-param> |
| 141 |
<xsl:with-param name="sectionId">Warnings_MALICIOUS_CODE</xsl:with-param> |
| 142 |
</xsl:call-template> |
| 143 |
|
| 144 |
<xsl:call-template name="generateWarningTable"> |
| 145 |
<xsl:with-param name="warningSet" select="BugInstance[@category='PERFORMANCE']"/> |
| 146 |
<xsl:with-param name="sectionTitle">Performance Warnings</xsl:with-param> |
| 147 |
<xsl:with-param name="sectionId">Warnings_PERFORMANCE</xsl:with-param> |
| 148 |
</xsl:call-template> |
| 149 |
|
| 150 |
<xsl:call-template name="generateWarningTable"> |
| 151 |
<xsl:with-param name="warningSet" select="BugInstance[@category='STYLE']"/> |
| 152 |
<xsl:with-param name="sectionTitle">Style Warnings</xsl:with-param> |
| 153 |
<xsl:with-param name="sectionId">Warnings_STYLE</xsl:with-param> |
| 154 |
</xsl:call-template> |
| 155 |
|
| 156 |
<hr width="98%" /> |
| 157 |
<br /> |
| 158 |
|
| 159 |
<dl> |
| 160 |
<xsl:for-each select="BugPattern"> |
| 161 |
<xsl:sort select="@abbrev"/> |
| 162 |
<xsl:sort select="ShortDescription"/> |
| 163 |
<dt><span class="findbugs-detailheader"><a name="{@type}"><xsl:value-of select="@type"/>: <xsl:value-of select="ShortDescription"/></a></span></dt> |
| 164 |
<dd><xsl:value-of select="Details" disable-output-escaping="yes"/></dd> |
| 165 |
</xsl:for-each> |
| 166 |
</dl> |
| 167 |
</td> |
| 168 |
</tr> |
| 169 |
</table> |
| 170 |
</xsl:template> |
| 171 |
|
| 172 |
<xsl:template match="Project" mode="findbugs"> |
| 173 |
<p>Project: <xsl:value-of select="@filename"/></p> |
| 174 |
<p>FindBugs version: <xsl:value-of select="../@version"/></p> |
| 175 |
|
| 176 |
<p>Code analyzed:</p> |
| 177 |
<ul> |
| 178 |
<xsl:for-each select="./Jar"> |
| 179 |
<li><xsl:value-of select="text()"/></li> |
| 180 |
</xsl:for-each> |
| 181 |
</ul> |
| 182 |
</xsl:template> |
| 183 |
|
| 184 |
<xsl:template match="BugInstance" mode="findbugs"> |
| 185 |
<xsl:variable name="warningId"><xsl:value-of select="generate-id()"/></xsl:variable> |
| 186 |
|
| 187 |
<tr class="findbugs-tablerow{position() mod 2}" onclick="toggleRow('{$warningId}');"> |
| 188 |
|
| 189 |
<td> |
| 190 |
<xsl:value-of select="@abbrev"/> |
| 191 |
</td> |
| 192 |
|
| 193 |
<td> |
| 194 |
<xsl:value-of select="substring-after(LongMessage,':')"/> |
| 195 |
</td> |
| 196 |
|
| 197 |
</tr> |
| 198 |
|
| 199 |
<!-- Add bug annotation elements: Class, Method, Field, SourceLine, Field --> |
| 200 |
<tr class="findbugs-detailrow{position() mod 2}"> |
| 201 |
<td/> |
| 202 |
<td> |
| 203 |
<p id="{$warningId}" style="display: none;"> |
| 204 |
<a href="#{@type}">Bug type <xsl:value-of select="@type"/> (click for details)</a> |
| 205 |
<xsl:for-each select="Class"> |
| 206 |
<xsl:sort select="@classname" /> |
| 207 |
<xsl:variable name="curClass"><xsl:value-of select="@classname" /></xsl:variable> |
| 208 |
<br/><xsl:value-of select="Message/text()" /> |
| 209 |
<xsl:apply-templates select="../SourceLine[@classname=$curClass]" mode="findbugs"> |
| 210 |
<xsl:sort select="@start" /> |
| 211 |
<xsl:sort select="@end" /> |
| 212 |
</xsl:apply-templates> |
| 213 |
<xsl:for-each select="../Method[@classname=$curClass]"> |
| 214 |
<br/><xsl:value-of select="Message/text()" /> |
| 215 |
<xsl:apply-templates select="SourceLine" mode="findbugs"> |
| 216 |
<xsl:sort select="@start" /> |
| 217 |
<xsl:sort select="@end" /> |
| 218 |
</xsl:apply-templates> |
| 219 |
</xsl:for-each> |
| 220 |
<xsl:for-each select="../Field[@classname=$curClass]"> |
| 221 |
<br/><xsl:value-of select="Message/text()" /> |
| 222 |
<xsl:apply-templates select="SourceLine" mode="findbugs"> |
| 223 |
<xsl:sort select="@start" /> |
| 224 |
<xsl:sort select="@end" /> |
| 225 |
</xsl:apply-templates> |
| 226 |
</xsl:for-each> |
| 227 |
</xsl:for-each> |
| 228 |
</p> |
| 229 |
</td> |
| 230 |
</tr> |
| 231 |
</xsl:template> |
| 232 |
|
| 233 |
<xsl:template match="SourceLine" mode="findbugs"> |
| 234 |
line <xsl:value-of select="@start" /> to <xsl:value-of select="@end" /> |
| 235 |
</xsl:template> |
| 236 |
|
| 237 |
<xsl:template name="generateWarningTable"> |
| 238 |
<xsl:param name="warningSet"/> |
| 239 |
<xsl:param name="sectionTitle"/> |
| 240 |
<xsl:param name="sectionId"/> |
| 241 |
|
| 242 |
<span class="findbugs-warningheader"><a name="{$sectionId}"><xsl:value-of select="$sectionTitle"/></a></span> |
| 243 |
<table class="findbugs-warningtable" width="100%" cellspacing="0"> |
| 244 |
<xsl:copy-of select="$bugTableHeader"/> |
| 245 |
<xsl:apply-templates select="$warningSet" mode="findbugs"> |
| 246 |
<xsl:sort select="@abbrev"/> |
| 247 |
<xsl:sort select="Class/@classname"/> |
| 248 |
</xsl:apply-templates> |
| 249 |
</table> |
| 250 |
<br /> |
| 251 |
</xsl:template> |
| 252 |
|
| 253 |
<xsl:template match="/"> |
| 254 |
<xsl:apply-templates select="." mode="findbugs" /> |
| 255 |
</xsl:template> |
| 256 |
|
| 257 |
</xsl:stylesheet> |
| 258 |
|
| 259 |
<!-- vim:set ts=4: --> |