diff options
Diffstat (limited to 'lib/findbugs/xsl/plain.xsl')
-rw-r--r-- | lib/findbugs/xsl/plain.xsl | 212 |
1 files changed, 158 insertions, 54 deletions
diff --git a/lib/findbugs/xsl/plain.xsl b/lib/findbugs/xsl/plain.xsl index d9dfaa3..80fff8d 100644 --- a/lib/findbugs/xsl/plain.xsl +++ b/lib/findbugs/xsl/plain.xsl @@ -21,20 +21,20 @@ <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output - method="html" + method="xml" omit-xml-declaration="yes" standalone="yes" - doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" + doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" + doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes" encoding="UTF-8"/> -<!--xsl:key name="bug-category-key" match="/BugCollection/BugInstance" use="@category"/--> - <xsl:variable name="bugTableHeader"> <tr class="tableheader"> <th align="left">Warning</th> + <th align="left">Priority</th> <th align="left">Details</th> </tr> </xsl:variable> @@ -68,18 +68,26 @@ </head> <xsl:variable name="unique-catkey" select="/BugCollection/BugCategory/@category"/> - <!--xsl:variable name="unique-catkey" select="/BugCollection/BugInstance[generate-id() = generate-id(key('bug-category-key',@category))]/@category"/--> - + <body> <h1>FindBugs Report</h1> + <p>Produced using <a href="http://findbugs.sourceforge.net">FindBugs</a> <xsl:value-of select="/BugCollection/@version"/>.</p> + <p>Project: + <xsl:choose> + <xsl:when test='string-length(/BugCollection/Project/@projectName)>0'><xsl:value-of select="/BugCollection/Project/@projectName" /></xsl:when> + <xsl:otherwise><xsl:value-of select="/BugCollection/Project/@filename" /></xsl:otherwise> + </xsl:choose> + </p> + <h2>Metrics</h2> + <xsl:apply-templates select="/BugCollection/FindBugsSummary"/> - <h2>Summary</h2>
- <table width="500" cellpadding="5" cellspacing="2">
- <tr class="tableheader">
- <th align="left">Warning Type</th>
- <th align="right">Number</th>
- </tr>
+ <h2>Summary</h2> + <table width="500" cellpadding="5" cellspacing="2"> + <tr class="tableheader"> + <th align="left">Warning Type</th> + <th align="right">Number</th> + </tr> <xsl:for-each select="$unique-catkey"> <xsl:sort select="." order="ascending"/> @@ -93,7 +101,7 @@ <tr class="{$styleclass}"> <td><a href="#Warnings_{$catkey}"><xsl:value-of select="$catdesc"/> Warnings</a></td> - <td align="right"><xsl:value-of select="count(/BugCollection/BugInstance[@category=$catkey])"/></td> + <td align="right"><xsl:value-of select="count(/BugCollection/BugInstance[(@category=$catkey) and (not(@last))])"/></td> </tr> </xsl:for-each> @@ -102,16 +110,16 @@ <xsl:otherwise>tablerow1</xsl:otherwise> </xsl:choose> </xsl:variable> - <tr class="{$styleclass}">
- <td><b>Total</b></td>
- <td align="right"><b><xsl:value-of select="count(/BugCollection/BugInstance)"/></b></td>
- </tr>
- </table>
- <p><br/><br/></p>
+ <tr class="{$styleclass}"> + <td><b>Total</b></td> + <td align="right"><b><xsl:value-of select="count(/BugCollection/BugInstance[not(@last)])"/></b></td> + </tr> + </table> + <p><br/><br/></p> <h1>Warnings</h1> - <p>Click on each warning link to see a full description of the issue, and
+ <p>Click on each warning link to see a full description of the issue, and details of how to resolve it.</p> <xsl:for-each select="$unique-catkey"> @@ -120,12 +128,12 @@ <xsl:variable name="catdesc" select="/BugCollection/BugCategory[@category=$catkey]/Description"/> <xsl:call-template name="generateWarningTable"> - <xsl:with-param name="warningSet" select="/BugCollection/BugInstance[@category=$catkey]"/> + <xsl:with-param name="warningSet" select="/BugCollection/BugInstance[(@category=$catkey) and (not(@last))]"/> <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> -
+ <p><br/><br/></p> <h1><a name="Details">Warning Types</a></h1> @@ -138,33 +146,41 @@ </html> </xsl:template> -<xsl:template match="BugInstance"> +<xsl:template match="BugInstance[not(@last)]"> <xsl:variable name="warningId"><xsl:value-of select="generate-id()"/></xsl:variable> <tr class="tablerow{position() mod 2}"> <td width="20%" valign="top"> <a href="#{@type}"><xsl:value-of select="ShortMessage"/></a> </td> - <td width="80%"> - <p><xsl:value-of select="LongMessage"/><br/><br/>
-
- <!-- add source filename and line number(s), if any -->
- <xsl:if test="SourceLine">
- <br/>In file <xsl:value-of select="SourceLine/@sourcefile"/>,
- <xsl:choose>
- <xsl:when test="SourceLine/@start = SourceLine/@end">
- line <xsl:value-of select="SourceLine/@start"/>
- </xsl:when>
- <xsl:otherwise>
- lines <xsl:value-of select="SourceLine/@start"/>
- to <xsl:value-of select="SourceLine/@end"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:for-each select="./*/Message">
- <br/><xsl:value-of select="text()"/>
- </xsl:for-each>
+ <td width="10%" valign="top"> + <xsl:choose> + <xsl:when test="@priority = 1">High</xsl:when> + <xsl:when test="@priority = 2">Medium</xsl:when> + <xsl:when test="@priority = 3">Low</xsl:when> + <xsl:otherwise>Unknown</xsl:otherwise> + </xsl:choose> + </td> + <td width="70%"> + <p><xsl:value-of select="LongMessage"/><br/><br/> + + <!-- add source filename and line number(s), if any --> + <xsl:if test="SourceLine"> + <br/>In file <xsl:value-of select="SourceLine/@sourcefile"/>, + <xsl:choose> + <xsl:when test="SourceLine/@start = SourceLine/@end"> + line <xsl:value-of select="SourceLine/@start"/> + </xsl:when> + <xsl:otherwise> + lines <xsl:value-of select="SourceLine/@start"/> + to <xsl:value-of select="SourceLine/@end"/> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + + <xsl:for-each select="./*/Message"> + <br/><xsl:value-of select="text()"/> + </xsl:for-each> </p> </td> </tr> @@ -172,7 +188,7 @@ <xsl:template match="BugPattern"> <h2><a name="{@type}"><xsl:value-of select="ShortDescription"/></a></h2> - <xsl:value-of select="Details" disable-output-escaping="yes"/>
+ <xsl:value-of select="Details" disable-output-escaping="yes"/> <p><br/><br/></p> </xsl:template> @@ -183,20 +199,108 @@ <h2><a name="{$sectionId}"><xsl:value-of select="$sectionTitle"/></a></h2> <table class="warningtable" width="100%" cellspacing="2" cellpadding="5"> - <xsl:copy-of select="$bugTableHeader"/>
- <xsl:choose>
+ <xsl:copy-of select="$bugTableHeader"/> + <xsl:choose> <xsl:when test="count($warningSet) > 0"> <xsl:apply-templates select="$warningSet"> + <xsl:sort select="@priority"/> <xsl:sort select="@abbrev"/> <xsl:sort select="Class/@classname"/> - </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <tr><td colspan="2"><p><i>None</i></p></td></tr>
- </xsl:otherwise>
+ </xsl:apply-templates> + </xsl:when> + <xsl:otherwise> + <tr><td colspan="2"><p><i>None</i></p></td></tr> + </xsl:otherwise> </xsl:choose> - </table>
+ </table> <p><br/><br/></p> </xsl:template> -</xsl:stylesheet>
\ No newline at end of file +<xsl:template match="FindBugsSummary"> + <xsl:variable name="kloc" select="@total_size div 1000.0"/> + <xsl:variable name="format" select="'#######0.00'"/> + + <p><xsl:value-of select="@total_size"/> lines of code analyzed, + in <xsl:value-of select="@total_classes"/> classes, + in <xsl:value-of select="@num_packages"/> packages.</p> + <table width="500" cellpadding="5" cellspacing="2"> + <tr class="tableheader"> + <th align="left">Metric</th> + <th align="right">Total</th> + <th align="right">Density*</th> + </tr> + <tr class="tablerow0"> + <td>High Priority Warnings</td> + <td align="right"><xsl:value-of select="@priority_1"/></td> + <td align="right"> + <xsl:choose> + <xsl:when test= "number($kloc) > 0.0"> + <xsl:value-of select="format-number(@priority_1 div $kloc, $format)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="format-number(0.0, $format)"/> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + <tr class="tablerow1"> + <td>Medium Priority Warnings</td> + <td align="right"><xsl:value-of select="@priority_2"/></td> + <td align="right"> + <xsl:choose> + <xsl:when test= "number($kloc) > 0.0"> + <xsl:value-of select="format-number(@priority_2 div $kloc, $format)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="format-number(0.0, $format)"/> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + + <xsl:choose> + <xsl:when test="@priority_3"> + <tr class="tablerow1"> + <td>Low Priority Warnings</td> + <td align="right"><xsl:value-of select="@priority_3"/></td> + <td align="right"> + <xsl:choose> + <xsl:when test= "number($kloc) > 0.0"> + <xsl:value-of select="format-number(@priority_3 div $kloc, $format)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="format-number(0.0, $format)"/> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + <xsl:variable name="totalClass" select="tablerow0"/> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="totalClass" select="tablerow1"/> + </xsl:otherwise> + </xsl:choose> + + <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:choose> + <xsl:when test= "number($kloc) > 0.0"> + <xsl:value-of select="format-number(@total_bugs div $kloc, $format)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="format-number(0.0, $format)"/> + </xsl:otherwise> + </xsl:choose> + </b> + </td> + </tr> + </table> + <p><i>(* Defects per Thousand lines of non-commenting source statements)</i></p> + <p><br/><br/></p> + +</xsl:template> + +</xsl:stylesheet> |