Fix flaky SummaryHTMLRenderer

This commit is contained in:
sandhu5
2023-11-22 23:01:06 -06:00
parent bdc08e44fd
commit 49bf440634
2 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@
package net.sourceforge.pmd.renderers;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
@ -74,7 +74,7 @@ public class SummaryHTMLRenderer extends AbstractAccumulatingRenderer {
}
private static Map<String, MutableInt> getSummary(Report report) {
Map<String, MutableInt> summary = new HashMap<>();
Map<String, MutableInt> summary = new LinkedHashMap<>();
for (RuleViolation rv : report.getViolations()) {
String name = rv.getRule().getName();
MutableInt count = summary.get(name);

View File

@ -69,8 +69,8 @@ class SummaryHTMLRendererTest extends AbstractRendererTest {
return "<html><head><title>PMD</title></head><body>" + EOL + "<center><h2>Summary</h2></center>" + EOL
+ "<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">" + EOL
+ "<tr><th>Rule name</th><th>Number of violations</th></tr>" + EOL
+ "<tr><td>Boo</td><td align=center>1</td></tr>" + EOL
+ "<tr><td>Foo</td><td align=center>1</td></tr>" + EOL + "</table>" + EOL
+ "<tr><td>Foo</td><td align=center>1</td></tr>" + EOL
+ "<tr><td>Boo</td><td align=center>1</td></tr>" + EOL + "</table>" + EOL
+ "<center><h2>Detail</h2></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>"
+ EOL
+ "<center><h3>PMD report</h3></center><center><h3>Problems found</h3></center><table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>"