Author: evenisse
Date: Mon May 9 17:20:29 2005
New Revision: 169385
URL: http://svn.apache.org/viewcvs?rev=169385&view=rev
Log:
Improve rendering.
Modified:
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
Modified:
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=169385&r1=169384&r2=169385&view=diff
==============================================================================
---
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
(original)
+++
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
Mon May 9 17:20:29 2005
@@ -89,7 +89,7 @@
PMD pmd = new PMD();
RuleContext ruleContext = new RuleContext();
Report report = new Report();
- PmdReportListener reportSink = new PmdReportListener( sink );
+ PmdReportListener reportSink = new PmdReportListener( sink,
getConfiguration().getSourceDirectory() );
report.addListener( reportSink );
ruleContext.setReport( report );
Modified:
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java?rev=169385&r1=169384&r2=169385&view=diff
==============================================================================
---
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
(original)
+++
maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReportListener.java
Mon May 9 17:20:29 2005
@@ -20,6 +20,7 @@
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.stat.Metric;
import org.codehaus.doxia.sink.Sink;
+import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@@ -32,16 +33,43 @@
public class PmdReportListener
implements ReportListener
{
- private Sink sink;
private static final String TITLE = "PMD Results";
- public PmdReportListener( Sink sink )
+ private Sink sink;
+
+ private String sourceDirectory;
+
+ private String currentFilename;
+
+ private boolean fileInitialized;
+
+ public PmdReportListener( Sink sink, String sourceDirectory )
{
this.sink = sink;
+ this.sourceDirectory = sourceDirectory;
}
public void ruleViolationAdded( RuleViolation ruleViolation )
{
+ if ( ! fileInitialized )
+ {
+ sink.section2();
+ sink.sectionTitle2();
+ sink.text( currentFilename );
+ sink.sectionTitle2_();
+
+ sink.table();
+ sink.tableRow();
+ sink.tableHeaderCell();
+ sink.text( "Violation" );
+ sink.tableHeaderCell_();
+ sink.tableHeaderCell();
+ sink.text( "Line" );
+ sink.tableHeaderCell_();
+ sink.tableRow_();
+
+ fileInitialized = true;
+ }
sink.tableRow();
sink.tableCell();
sink.text( ruleViolation.getDescription() );
@@ -92,26 +120,18 @@
public void beginFile( File file )
{
- sink.section2();
- sink.sectionTitle2();
- sink.text( file.getPath() );
- sink.sectionTitle2_();
-
- sink.table();
- sink.tableRow();
- sink.tableHeaderCell();
- sink.text( "Violation" );
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- sink.text( "Line" );
- sink.tableHeaderCell_();
- sink.tableRow_();
+ currentFilename = StringUtils.substring( file.getAbsolutePath(),
sourceDirectory.length() + 1 );
+ currentFilename = StringUtils.replace( currentFilename, "\\", "/" );
+ fileInitialized = false;
}
public void endFile( File file )
{
- sink.table_();
- sink.section2_();
+ if ( fileInitialized )
+ {
+ sink.table_();
+ sink.section2_();
+ }
}
public void endDocument()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]