Supply a default xsl file for generating the checkstyle report.
Project: http://git-wip-us.apache.org/repos/asf/buildr/repo Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/8ff8748f Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/8ff8748f Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/8ff8748f Branch: refs/heads/master Commit: 8ff8748faee409e57a90f8a5087a0136e14811a6 Parents: 4408204 Author: Peter Donald <[email protected]> Authored: Sat May 24 13:41:58 2014 +1000 Committer: Peter Donald <[email protected]> Committed: Sat May 24 13:56:24 2014 +1000 ---------------------------------------------------------------------- CHANGELOG | 2 + addon/buildr/checkstyle-report.xsl | 87 +++++++++++++++++++++++++++++++++ addon/buildr/checkstyle.rb | 10 +++- doc/more_stuff.textile | 4 +- 4 files changed, 100 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/buildr/blob/8ff8748f/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 22c84c3..4ce053b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ 1.4.17 (Pending) * Fixed: Fix the vcs detection in IDEA addon for 1.8.6 (!) versions of ruby by reordering blocks. +* Change: Supply a default xsl file for generating the checkstyle + report. * Added: Add scss_lint tasks scss_lint:xml and scss_lint:html that support source code analysis of SCSS files. * Added: Import 'buildr/custom_pom' addon to make it easier to http://git-wip-us.apache.org/repos/asf/buildr/blob/8ff8748f/addon/buildr/checkstyle-report.xsl ---------------------------------------------------------------------- diff --git a/addon/buildr/checkstyle-report.xsl b/addon/buildr/checkstyle-report.xsl new file mode 100644 index 0000000..07843a4 --- /dev/null +++ b/addon/buildr/checkstyle-report.xsl @@ -0,0 +1,87 @@ +<?xml version="1.0"?> + +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <xsl:template match="/"> + <html> + <head> + <title>Checkstyle Violations</title> + </head> + <body bgcolor="#FFFFEF"> + <p> + <b>Coding Style Check Results</b> + </p> + <table border="1" cellspacing="0" cellpadding="2"> + <tr bgcolor="#CC9966"> + <th colspan="2"> + <b>Summary</b> + </th> + </tr> + <tr bgcolor="#CCF3D0"> + <td>Total files checked</td> + <td> + <xsl:number level="any" value="count(descendant::file)"/> + </td> + </tr> + <tr bgcolor="#F3F3E1"> + <td>Files with errors</td> + <td> + <xsl:number level="any" value="count(descendant::file[error])"/> + </td> + </tr> + <tr bgcolor="#CCF3D0"> + <td>Total errors</td> + <td> + <xsl:number level="any" value="count(descendant::error)"/> + </td> + </tr> + <tr bgcolor="#F3F3E1"> + <td>Errors per file</td> + <td> + <xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/> + </td> + </tr> + </table> + <hr align="left" width="95%" size="1"/> + <p>The following are violations of the Checkstyle Rules:</p> + <p/> + <xsl:apply-templates/> + </body> + </html> + </xsl:template> + + <xsl:template match="file[error]"> + <table bgcolor="#AFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2"> + <tr> + <th>File:</th> + <td> + <xsl:value-of select="@name"/> + </td> + </tr> + </table> + <table bgcolor="#DFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2"> + <tr> + <th>Line Number</th> + <th>Error Message</th> + <th>Check</th> + </tr> + <xsl:apply-templates select="error"/> + </table> + <p/> + </xsl:template> + + <xsl:template match="error"> + <tr> + <td> + <xsl:value-of select="@line"/> + </td> + <td> + <xsl:value-of select="@message"/> + </td> + <td> + <xsl:value-of select="@source"/> + </td> + </tr> + </xsl:template> + +</xsl:stylesheet> http://git-wip-us.apache.org/repos/asf/buildr/blob/8ff8748f/addon/buildr/checkstyle.rb ---------------------------------------------------------------------- diff --git a/addon/buildr/checkstyle.rb b/addon/buildr/checkstyle.rb index c909934..2175948 100644 --- a/addon/buildr/checkstyle.rb +++ b/addon/buildr/checkstyle.rb @@ -116,7 +116,15 @@ module Buildr attr_writer :style_file def style_file - @style_file || "#{self.config_directory}/checkstyle-report.xsl" + unless @style_file + project_xsl = "#{self.config_directory}/checkstyle-report.xsl" + if File.exist?(project_xsl) + @style_file = project_xsl + else + @style_file = "#{File.dirname(__FILE__)}/checkstyle-report.xsl" + end + end + @style_file end attr_writer :suppressions_file http://git-wip-us.apache.org/repos/asf/buildr/blob/8ff8748f/doc/more_stuff.textile ---------------------------------------------------------------------- diff --git a/doc/more_stuff.textile b/doc/more_stuff.textile index fe26bba..cc1eafc 100644 --- a/doc/more_stuff.textile +++ b/doc/more_stuff.textile @@ -884,7 +884,7 @@ $ buildr -rbuildr/java/cobertura cobertura:html h2(#checkstyle). Checkstyle -Checkstyle is integrated into Buildr through an extension. The extension adds the "checkstyle:xml" task that generates an xml report listing checkstyle violations and may add a "checkstyle:html" task if an appropriate xsl is present. A typical project that uses the extension may look something like; +Checkstyle is integrated into Buildr through an extension. The extension adds the "checkstyle:xml" task that generates an xml report listing checkstyle violations and a "checkstyle:html" task to generate the html variant. A typical project that uses the extension may look something like; {% highlight ruby %} require 'buildr/checkstyle' @@ -905,7 +905,7 @@ By default checkstyle will look for all configuration files in the src/main/etc/ The extension will include the source and test directories of the project aswell as the compile and test dependencies when invoking the checkstyle tool. These can be added to by the parameters "checkstyle.source_paths" and "checkstyle.extra_dependencies" as appropriate. -If the xsl file named "checkstyle-report.xsl" is present in the configuration directory then a "checkstyle:html" task will be defined. The name of the xsl file can be overridden by the parameter "checkstyle.style_file". +If the xsl file named "checkstyle-report.xsl" is present in the configuration directory then it will be used to generate the html report, otherwise a xsl file that comes with buildr will be used. The name of the xsl file can be overridden by the parameter "checkstyle.style_file". h2(#findbugs). FindBugs
