[MPMD-282] Add rule name to HTML report
And also fix no problem message
diff --git a/src/it/mpmd-168-empty-report/verify.groovy b/src/it/mpmd-168-empty-report/verify.groovy
index 2870b7a..6ee06d2 100644
--- a/src/it/mpmd-168-empty-report/verify.groovy
+++ b/src/it/mpmd-168-empty-report/verify.groovy
@@ -26,12 +26,14 @@
File pmdReportInSite = new File( siteDir, "pmd.html" )
assert pmdReportInSite.exists()
+assert pmdReportInSite.getText( "UTF-8" ).contains( "PMD found no problems in your source code." )
File pmdXmlInTarget = new File( targetDir, "pmd.xml" )
assert pmdXmlInTarget.exists()
File cpdReportInSite = new File( siteDir, "cpd.html" )
assert cpdReportInSite.exists()
+assert cpdReportInSite.getText( "UTF-8" ).contains( "CPD found no problems in your source code." )
File cpdXmlInTarget = new File( targetDir, "cpd.xml" )
assert cpdXmlInTarget.exists()
diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
index d76ad73..1d744b8 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReportGenerator.java
@@ -62,9 +62,6 @@
private boolean renderRuleViolationPriority;
- // The number of erroneous files
- private int fileCount = 0;
-
private Map<File, PmdFileInfo> files;
// private List<Metric> metrics = new ArrayList<Metric>();
@@ -159,6 +156,9 @@
sink.table();
sink.tableRow();
sink.tableHeaderCell();
+ sink.text( bundle.getString( "report.pmd.column.rule" ) );
+ sink.tableHeaderCell_();
+ sink.tableHeaderCell();
sink.text( bundle.getString( "report.pmd.column.violation" ) );
sink.tableHeaderCell_();
if ( this.renderRuleViolationPriority )
@@ -183,6 +183,11 @@
{
sink.tableRow();
sink.tableCell();
+ sink.link( ruleViolation.getRule().getExternalInfoUrl() );
+ sink.text( ruleViolation.getRule().getName() );
+ sink.link_();
+ sink.tableCell_();
+ sink.tableCell();
sink.text( ruleViolation.getDescription() );
sink.tableCell_();
@@ -200,7 +205,7 @@
int endLine = ruleViolation.getEndLine();
if ( endLine != beginLine )
{
- sink.text( "–" );
+ sink.text( "–" ); // \u2013 is a medium long dash character
outputLineLink( endLine, fileInfo );
}
@@ -221,7 +226,6 @@
// TODO files summary
- fileCount = files.size();
List<RuleViolation> violations2 = new ArrayList<>( violations );
Collections.sort( violations2, new Comparator<RuleViolation>()
{
@@ -268,7 +272,7 @@
endFileSection();
}
- if ( fileCount == 0 )
+ if ( violations.isEmpty() )
{
sink.paragraph();
sink.text( bundle.getString( "report.pmd.noProblems" ) );
diff --git a/src/main/resources/pmd-report.properties b/src/main/resources/pmd-report.properties
index 6b2cd01..df6632f 100644
--- a/src/main/resources/pmd-report.properties
+++ b/src/main/resources/pmd-report.properties
@@ -18,6 +18,7 @@
report.pmd.name=PMD
report.pmd.description=Verification of coding rules.
report.pmd.title=PMD Results
+report.pmd.column.rule=Rule
report.pmd.column.violation=Violation
report.pmd.column.priority=Priority
report.pmd.column.line=Line
diff --git a/src/main/resources/pmd-report_de.properties b/src/main/resources/pmd-report_de.properties
index de8ee93..6cdcd10 100644
--- a/src/main/resources/pmd-report_de.properties
+++ b/src/main/resources/pmd-report_de.properties
@@ -18,6 +18,7 @@
report.pmd.name=PMD
report.pmd.description=Verifikation von Code-Richtlinien.
report.pmd.title=PMD Ergebnisse
+report.pmd.column.rule=Regel
report.pmd.column.violation=Versto\u00df
report.pmd.column.priority=Priorit\u00e4t
report.pmd.column.line=Zeile
diff --git a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
index 88a794c..2dac659 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -58,6 +59,7 @@
throws Exception
{
super.setUp();
+ Locale.setDefault( Locale.ENGLISH );
FileUtils.deleteDirectory( new File( getBasedir(), "target/test/unit" ) );
}
@@ -300,6 +302,7 @@
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
String str = readFile( new File( getBasedir(), "target/test/unit/empty-report/target/site/cpd.html" ) );
assertFalse( lowerCaseContains( str, "Hello.java" ) );
+ assertTrue( str.contains( "CPD found no problems in your source code." ) );
}
public void testCpdEncodingConfiguration()
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index eb2fa23..1ed3647 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -89,7 +89,12 @@
assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L45" ) );
// check if there's a priority column
- assertTrue( str.contains( "Priority" ) );
+ assertTrue( str.contains( "<th>Priority</th>" ) );
+
+ // there should be a rule column
+ assertTrue( str.contains( "<th>Rule</th>" ) );
+ // along with a link to the rule
+ assertTrue( str.contains( "pmd_rules_java_bestpractices.html#unusedprivatefield\">UnusedPrivateField</a>" ) );
}
public void testDefaultConfigurationNotRenderRuleViolationPriority()
@@ -339,6 +344,7 @@
assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
String str = readFile( generatedFile );
assertFalse( lowerCaseContains( str, "Hello.java" ) );
+ assertTrue( str.contains( "PMD found no problems in your source code." ) );
}
public void testInvalidFormat()