diff --git a/src/it/mpmd-168-empty-report/verify.groovy b/src/it/mpmd-168-empty-report/verify.groovy index 2870b7a3..6ee06d2c 100644 --- a/src/it/mpmd-168-empty-report/verify.groovy +++ b/src/it/mpmd-168-empty-report/verify.groovy @@ -26,12 +26,14 @@ assert projectReports.getText( "UTF-8" ).contains( "cpd.html" ) 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 d76ad73f..1d744b8d 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 @@ public class PmdReportGenerator private boolean renderRuleViolationPriority; - // The number of erroneous files - private int fileCount = 0; - private Map files; // private List metrics = new ArrayList(); @@ -159,6 +156,9 @@ private void startFileSection( String currentFilename, PmdFileInfo fileInfo ) 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 @@ private void processSingleRuleViolation( RuleViolation ruleViolation, PmdFileInf { 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 @@ private void processSingleRuleViolation( RuleViolation ruleViolation, PmdFileInf 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 @@ private void processViolations() // TODO files summary - fileCount = files.size(); List violations2 = new ArrayList<>( violations ); Collections.sort( violations2, new Comparator() { @@ -268,7 +272,7 @@ public int compare( RuleViolation o1, RuleViolation o2 ) 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 6b2cd01a..df6632f2 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 de8ee931..6cdcd100 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 88a794cd..2dac659d 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 @@ protected void setUp() throws Exception { super.setUp(); + Locale.setDefault( Locale.ENGLISH ); FileUtils.deleteDirectory( new File( getBasedir(), "target/test/unit" ) ); } @@ -300,6 +302,7 @@ public void testEmptyReportConfiguration() 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 eb2fa231..1ed3647f 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 @@ public void testDefaultConfiguration() assertTrue( str.contains( "/xref/def/configuration/AppSample.html#L45" ) ); // check if there's a priority column - assertTrue( str.contains( "Priority" ) ); + assertTrue( str.contains( "Priority" ) ); + + // there should be a rule column + assertTrue( str.contains( "Rule" ) ); + // along with a link to the rule + assertTrue( str.contains( "pmd_rules_java_bestpractices.html#unusedprivatefield\">UnusedPrivateField" ) ); } public void testDefaultConfigurationNotRenderRuleViolationPriority() @@ -339,6 +344,7 @@ public void testEmptyReportConfiguration() 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()