Skip to content

Commit 4bc9ae0

Browse files
committed
Render config errors
1 parent cdb9262 commit 4bc9ae0

File tree

7 files changed

+149
-0
lines changed

7 files changed

+149
-0
lines changed

lib/pmdtester/builders/liquid_renderer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def write_project_index(project, root)
4949
liquid_env = {
5050
'diff' => report_diff_to_h(project.report_diff),
5151
'error_diffs' => errors_to_h(project),
52+
'configerror_diffs' => configerrors_to_h(project),
5253
'project_name' => project.name
5354
}
5455

lib/pmdtester/builders/project_hasher.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def report_diff_to_h(rdiff)
1111
{
1212
'violation_counts' => rdiff.violation_counts.to_h,
1313
'error_counts' => rdiff.error_counts.to_h,
14+
'configerror_counts' => rdiff.configerror_counts.to_h,
1415

1516
'base_execution_time' => PmdReportDetail.convert_seconds(rdiff.base_report.exec_time),
1617
'patch_execution_time' => PmdReportDetail.convert_seconds(rdiff.patch_report.exec_time),
@@ -29,6 +30,11 @@ def errors_to_h(project)
2930
errors.map { |e| error_to_hash(e, project) }
3031
end
3132

33+
def configerrors_to_h(project)
34+
configerrors = project.report_diff.configerror_diffs_by_rule.values.flatten
35+
configerrors.map { |e| configerror_to_hash(e) }
36+
end
37+
3238
def violations_to_hash(project)
3339
filename_index = []
3440
all_vs = []
@@ -99,6 +105,14 @@ def sanitize_stacktrace(error)
99105
.gsub(/\w++(?=\(\w++\.java:\d++\))/, '<span class="stack-trace-method">\\0</span>')
100106
end
101107

108+
def configerror_to_hash(configerror)
109+
{
110+
'rule' => configerror.rulename,
111+
'message' => configerror.msg,
112+
'change_type' => change_type(configerror)
113+
}
114+
end
115+
102116
def change_type(item)
103117
if item.branch == BASE
104118
'removed'

resources/project_diff_report.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ <h2>Summary</h2>
4848
{% include 'diff_pill_row' h: diff.error_counts %}
4949
</td>
5050
</tr>
51+
<tr>
52+
<td class="item"><a href="#section-configerrors">ConfigErrors</a></td>
53+
<td class="base">{{diff.configerror_counts.base_total}}</td>
54+
<td class="patch">{{diff.configerror_counts.patch_total}}</td>
55+
<td class="diff">
56+
{% include 'diff_pill_row' h: diff.configerror_counts %}
57+
</td>
58+
</tr>
5159
<tr>
5260
<td class="item">Execution time</td>
5361
<td class="base">{{diff.base_execution_time}}</td>
@@ -164,6 +172,33 @@ <h2>Errors</h2>
164172
</div>
165173
</div>
166174

175+
<div class="section" id="section-configerrors">
176+
177+
<h2>ConfigErrors</h2>
178+
179+
<div class="section-content">
180+
181+
<div class="table-responsive">
182+
<table id="configerror-table" class="table">
183+
<thead>
184+
<tr>
185+
<th>Rule</th>
186+
<th>Message</th>
187+
</tr>
188+
</thead>
189+
<tbody>
190+
{% for configerror in configerror_diffs %}
191+
<tr class="configerror-row {{configerror.change_type}}">
192+
<td>{{configerror.rule}}</td>
193+
<td>{{configerror.message}}</td>
194+
</tr>
195+
{% endfor %}
196+
</tbody>
197+
</table>
198+
</div>
199+
</div>
200+
</div>
201+
167202
<script src="../js/project-report.js"></script>
168203

169204
</body>

resources/project_index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ <h2>Projects</h2>
7777
<th>Tag</th>
7878
<th>Violation diff</th>
7979
<th>Error diff</th>
80+
<th>ConfigError diff</th>
8081
</tr>
8182
</thead>
8283
<tbody>
@@ -89,6 +90,7 @@ <h2>Projects</h2>
8990
<td>{{ project.tag }}</td>
9091
<td>{% include 'diff_pill_row' h: project.violation_counts %}</td>
9192
<td>{% include 'diff_pill_row' h: project.error_counts %}</td>
93+
<td>{% include 'diff_pill_row' h: project.configerror_counts %}</td>
9294
</tr>
9395
{% endfor %}
9496
</tbody>

test/resources/html_report_builder/expected_diff_report_index.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ <h2>Summary</h2>
5858
<span class="pill badge-pill badge-secondary changed">~1</span>
5959

6060

61+
</td>
62+
</tr>
63+
<tr>
64+
<td class="item"><a href="#section-configerrors">ConfigErrors</a></td>
65+
<td class="base">1</td>
66+
<td class="patch">2</td>
67+
<td class="diff">
68+
69+
<span class="pill badge-pill badge-secondary added">+1</span>
70+
<span class="pill badge-pill badge-secondary removed">-0</span>
71+
72+
<span class="pill badge-pill badge-secondary changed">~0</span>
73+
74+
6175
</td>
6276
</tr>
6377
<tr>
@@ -250,6 +264,31 @@ <h2>Errors</h2>
250264
</div>
251265
</div>
252266

267+
<div class="section" id="section-configerrors">
268+
269+
<h2>ConfigErrors</h2>
270+
271+
<div class="section-content">
272+
273+
<div class="table-responsive">
274+
<table id="configerror-table" class="table">
275+
<thead>
276+
<tr>
277+
<th>Rule</th>
278+
<th>Message</th>
279+
</tr>
280+
</thead>
281+
<tbody>
282+
<tr class="configerror-row added">
283+
<td>NewRule</td>
284+
<td>Property method_name not defined</td>
285+
</tr>
286+
</tbody>
287+
</table>
288+
</div>
289+
</div>
290+
</div>
291+
253292
<script src="../js/project-report.js"></script>
254293

255294
</body>

test/resources/html_report_builder/expected_empty_diff_report.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ <h2>Summary</h2>
5555
<span class="pill badge-pill badge-secondary added">+0</span>
5656
<span class="pill badge-pill badge-secondary removed">-0</span>
5757

58+
<span class="pill badge-pill badge-secondary changed">~0</span>
59+
60+
61+
</td>
62+
</tr>
63+
<tr>
64+
<td class="item"><a href="#section-configerrors">ConfigErrors</a></td>
65+
<td class="base">0</td>
66+
<td class="patch">0</td>
67+
<td class="diff">
68+
69+
<span class="pill badge-pill badge-secondary added">+0</span>
70+
<span class="pill badge-pill badge-secondary removed">-0</span>
71+
5872
<span class="pill badge-pill badge-secondary changed">~0</span>
5973

6074

@@ -148,6 +162,28 @@ <h2>Errors</h2>
148162
</div>
149163
</div>
150164

165+
<div class="section" id="section-configerrors">
166+
167+
<h2>ConfigErrors</h2>
168+
169+
<div class="section-content">
170+
171+
<div class="table-responsive">
172+
<table id="configerror-table" class="table">
173+
<thead>
174+
<tr>
175+
<th>Rule</th>
176+
<th>Message</th>
177+
</tr>
178+
</thead>
179+
<tbody>
180+
181+
</tbody>
182+
</table>
183+
</div>
184+
</div>
185+
</div>
186+
151187
<script src="../js/project-report.js"></script>
152188

153189
</body>

test/resources/summary_report_builder/expected_index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ <h2>Projects</h2>
7575
<th>Tag</th>
7676
<th>Violation diff</th>
7777
<th>Error diff</th>
78+
<th>ConfigError diff</th>
7879
</tr>
7980
</thead>
8081
<tbody>
@@ -98,6 +99,13 @@ <h2>Projects</h2>
9899

99100
<span class="pill badge-pill badge-secondary changed">~0</span>
100101

102+
</td>
103+
<td>
104+
<span class="pill badge-pill badge-secondary added">+0</span>
105+
<span class="pill badge-pill badge-secondary removed">-0</span>
106+
107+
<span class="pill badge-pill badge-secondary changed">~0</span>
108+
101109
</td>
102110
</tr>
103111

@@ -117,6 +125,13 @@ <h2>Projects</h2>
117125

118126
<span class="pill badge-pill badge-secondary changed">~0</span>
119127

128+
</td>
129+
<td>
130+
<span class="pill badge-pill badge-secondary added">+0</span>
131+
<span class="pill badge-pill badge-secondary removed">-0</span>
132+
133+
<span class="pill badge-pill badge-secondary changed">~0</span>
134+
120135
</td>
121136
</tr>
122137

@@ -136,6 +151,13 @@ <h2>Projects</h2>
136151

137152
<span class="pill badge-pill badge-secondary changed">~0</span>
138153

154+
</td>
155+
<td>
156+
<span class="pill badge-pill badge-secondary added">+0</span>
157+
<span class="pill badge-pill badge-secondary removed">-0</span>
158+
159+
<span class="pill badge-pill badge-secondary changed">~0</span>
160+
139161
</td>
140162
</tr>
141163

0 commit comments

Comments
 (0)