Skip to content

Commit e9bce65

Browse files
committed
Update tests
1 parent cbd55f4 commit e9bce65

File tree

5 files changed

+35
-64
lines changed

5 files changed

+35
-64
lines changed

lib/pmdtester/report_diff.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ def calculate_violations(base_violations, patch_violations)
9494
@violation_diffs = merge_changed_violations(@violation_diffs)
9595

9696
@new_violations_size, @changed_violations_size, @removed_violations_size = get_diffs_size(@violation_diffs)
97-
@violation_diffs_size = @violation_diffs.size
97+
@violation_diffs_size = @new_violations_size + @changed_violations_size + @removed_violations_size
9898
end
9999

100100
def calculate_errors(base_errors, patch_errors)
101101
@base_errors_size = base_errors.errors_size
102102
@patch_errors_size = patch_errors.errors_size
103103
@error_diffs = build_diffs(base_errors.errors, patch_errors.errors)
104104
@new_errors_size, _, @removed_errors_size = get_diffs_size(@error_diffs)
105-
@error_diffs_size = @error_diffs.size
105+
@error_diffs_size = @new_errors_size + @removed_errors_size
106106
end
107107

108108
def calculate_configerrors(base_configerrors, patch_configerrors)
109109
@base_configerrors_size = base_configerrors.size
110110
@patch_configerrors_size = patch_configerrors.size
111111
@configerrors_diffs = build_diffs(base_configerrors.errors, patch_configerrors.errors)
112112
@new_configerrors_size, _, @removed_configerrors_size = get_diffs_size(@configerrors_diffs)
113-
@configerrors_diffs_size = @configerrors_diffs.size
113+
@configerrors_diffs_size = @new_configerrors_size + @removed_configerrors_size
114114
end
115115

116116
def calculate_details(base_info, patch_info)

test/resources/html_report_builder/expected_diff_report_index.html

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ <h2>Summary:</h2>
2020
<td class="b">1</td>
2121
<td class="a">1</td>
2222
<td class="c">
23-
<font color="red">-1</font> | <font color="green">+1</font>
23+
<span class="removed">-1</span> | <span class="added">+1</span>
2424
</td>
2525
</tr>
2626
<tr>
2727
<td class="c"><a href="#Violations">number of violations</a></td>
2828
<td class="b">5</td>
2929
<td class="a">8</td>
3030
<td class="c">
31-
<font color="red">-2</font> | <font color="green">+5</font>
31+
<span class="removed">-1</span> | <span class="changed">~1</span> | <span class="added">+4</span>
3232
</td>
3333
</tr>
3434
<tr>
3535
<td class="c"><a href="#configerrors">number of config errors</a></td>
3636
<td class="b">1</td>
3737
<td class="a">2</td>
3838
<td class="c">
39-
<font color="red">-0</font> | <font color="green">+1</font>
39+
<span class="removed">-0</span> | <span class="added">+1</span>
4040
</td>
4141
</tr>
4242
<tr>
@@ -61,18 +61,14 @@ <h3><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.REL
6161
<table class="bodyTable" border="0">
6262
<thead><tr>
6363
<th></th>
64-
<th>Priority</th>
6564
<th>Rule</th>
6665
<th>Message</th>
6766
<th>Line</th>
6867
</tr></thead>
6968
<tbody><tr class="b">
7069
<td><a id="A1" href="#A1">#</a></td>
71-
<td>3</td>
7270
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass">FieldDeclarationsShouldBeAtStartOfClass</a></td>
73-
<td>
74-
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
75-
</td>
71+
<td>Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.</td>
7672
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/Pointcut.java#L51">51</a></td>
7773
</tr></tbody>
7874
</table>
@@ -82,37 +78,21 @@ <h3><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.REL
8278
<table class="bodyTable" border="0">
8379
<thead><tr>
8480
<th></th>
85-
<th>Priority</th>
8681
<th>Rule</th>
8782
<th>Message</th>
8883
<th>Line</th>
8984
</tr></thead>
9085
<tbody>
91-
<tr class="b">
86+
<tr class="d">
9287
<td><a id="A2" href="#A2">#</a></td>
93-
<td>3</td>
9488
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_design.html#godclass">GodClass</a></td>
95-
<td>
96-
Possible God Class (WMC=101, ATFD=29, TCC=3.374%)
97-
</td>
89+
<td>Possible God Class (WMC=101, ATFD=29, TCC=<del class="differ">4</del><ins class="differ">3</ins>.<del class="differ">000</del><ins class="differ">374</ins>%)</td>
9890
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java#L63">63</a></td>
9991
</tr>
10092
<tr class="a">
10193
<td><a id="A3" href="#A3">#</a></td>
102-
<td>3</td>
103-
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_design.html#godclass">GodClass</a></td>
104-
<td>
105-
Possible God Class (WMC=101, ATFD=29, TCC=4.000%)
106-
</td>
107-
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java#L63">63</a></td>
108-
</tr>
109-
<tr class="a">
110-
<td><a id="A4" href="#A4">#</a></td>
111-
<td>3</td>
11294
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass">FieldDeclarationsShouldBeAtStartOfClass</a></td>
113-
<td>
114-
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
115-
</td>
95+
<td>Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.</td>
11696
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java#L96">96</a></td>
11797
</tr>
11898
</tbody>
@@ -123,18 +103,14 @@ <h3><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.REL
123103
<table class="bodyTable" border="0">
124104
<thead><tr>
125105
<th></th>
126-
<th>Priority</th>
127106
<th>Rule</th>
128107
<th>Message</th>
129108
<th>Line</th>
130109
</tr></thead>
131110
<tbody><tr class="a">
132-
<td><a id="A5" href="#A5">#</a></td>
133-
<td>3</td>
111+
<td><a id="A4" href="#A4">#</a></td>
134112
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass">FieldDeclarationsShouldBeAtStartOfClass</a></td>
135-
<td>
136-
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
137-
</td>
113+
<td>Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.</td>
138114
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/ClassFilter.java#L44">44</a></td>
139115
</tr></tbody>
140116
</table>
@@ -144,18 +120,14 @@ <h3><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.REL
144120
<table class="bodyTable" border="0">
145121
<thead><tr>
146122
<th></th>
147-
<th>Priority</th>
148123
<th>Rule</th>
149124
<th>Message</th>
150125
<th>Line</th>
151126
</tr></thead>
152127
<tbody><tr class="a">
153-
<td><a id="A6" href="#A6">#</a></td>
154-
<td>3</td>
128+
<td><a id="A5" href="#A5">#</a></td>
155129
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass">FieldDeclarationsShouldBeAtStartOfClass</a></td>
156-
<td>
157-
Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.
158-
</td>
130+
<td>Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes.</td>
159131
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/MethodMatcher.java#L97">97</a></td>
160132
</tr></tbody>
161133
</table>
@@ -165,18 +137,14 @@ <h3><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.REL
165137
<table class="bodyTable" border="0">
166138
<thead><tr>
167139
<th></th>
168-
<th>Priority</th>
169140
<th>Rule</th>
170141
<th>Message</th>
171142
<th>Line</th>
172143
</tr></thead>
173144
<tbody><tr class="a">
174-
<td><a id="A7" href="#A7">#</a></td>
175-
<td>1</td>
145+
<td><a id="A6" href="#A6">#</a></td>
176146
<td><a href="http://pmd.sourceforge.net/snapshot/pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal">ClassWithOnlyPrivateConstructorsShouldBeFinal</a></td>
177-
<td>
178-
A class which only has private constructors should be final
179-
</td>
147+
<td>A class which only has private constructors should be final</td>
180148
<td><a href="https://github.com/spring-projects/spring-framework/tree/v5.0.6.RELEASE/spring-aop/src/main/java/org/springframework/aop/TrueClassFilter.java#L27">27</a></td>
181149
</tr></tbody>
182150
</table>

test/resources/html_report_builder/expected_empty_diff_report.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ <h2>Summary:</h2>
2020
<td class="b">0</td>
2121
<td class="a">0</td>
2222
<td class="c">
23-
<font color="red">-0</font> | <font color="green">+0</font>
23+
<span class="removed">-0</span> | <span class="added">+0</span>
2424
</td>
2525
</tr>
2626
<tr>
2727
<td class="c"><a href="#Violations">number of violations</a></td>
2828
<td class="b">0</td>
2929
<td class="a">0</td>
3030
<td class="c">
31-
<font color="red">-0</font> | <font color="green">+0</font>
31+
<span class="removed">-0</span> | <span class="added">+0</span>
3232
</td>
3333
</tr>
3434
<tr>
3535
<td class="c"><a href="#configerrors">number of config errors</a></td>
3636
<td class="b">0</td>
3737
<td class="a">0</td>
3838
<td class="c">
39-
<font color="red">-0</font> | <font color="green">+0</font>
39+
<span class="removed">-0</span> | <span class="added">+0</span>
4040
</td>
4141
</tr>
4242
<tr>

test/resources/summary_report_builder/expected_index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,39 +70,39 @@ <h2>Projects:</h2>
7070
<td><a href="./checkstyle/index.html">checkstyle</a></td>
7171
<td>master</td>
7272
<td>
73-
<font color="red">-0</font> | <font color="green">+0</font>
73+
<span class="removed">-0</span> | <span class="added">+0</span>
7474
</td>
7575
<td>
76-
<font color="red">-0</font> | <font color="green">+0</font>
76+
<span class="removed">-0</span> | <span class="added">+0</span>
7777
</td>
7878
<td>
79-
<font color="red">-0</font> | <font color="green">+0</font>
79+
<span class="removed">-0</span> | <span class="added">+0</span>
8080
</td>
8181
</tr>
8282
<tr>
8383
<td><a href="./openjdk10/index.html">openjdk10</a></td>
8484
<td>master</td>
8585
<td>
86-
<font color="red">-0</font> | <font color="green">+0</font>
86+
<span class="removed">-0</span> | <span class="added">+0</span>
8787
</td>
8888
<td>
89-
<font color="red">-0</font> | <font color="green">+0</font>
89+
<span class="removed">-0</span> | <span class="added">+0</span>
9090
</td>
9191
<td>
92-
<font color="red">-0</font> | <font color="green">+0</font>
92+
<span class="removed">-0</span> | <span class="added">+0</span>
9393
</td>
9494
</tr>
9595
<tr>
9696
<td><a href="./spring-framework/index.html">spring-framework</a></td>
9797
<td>v5.0.6.RELEASE</td>
9898
<td>
99-
<font color="red">-0</font> | <font color="green">+0</font>
99+
<span class="removed">-0</span> | <span class="added">+0</span>
100100
</td>
101101
<td>
102-
<font color="red">-0</font> | <font color="green">+0</font>
102+
<span class="removed">-0</span> | <span class="added">+0</span>
103103
</td>
104104
<td>
105-
<font color="red">-0</font> | <font color="green">+0</font>
105+
<span class="removed">-0</span> | <span class="added">+0</span>
106106
</td>
107107
</tr>
108108
</tbody>

test/test_diff_builder.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ def test_violation_diffs
2525
assert_empty(diffs_report.configerrors_diffs)
2626
assert_equal(5, diffs_report.base_violations_size)
2727
assert_equal(8, diffs_report.patch_violations_size)
28-
assert_equal(7, diffs_report.violation_diffs_size)
29-
assert_equal(2, diffs_report.removed_violations_size)
30-
assert_equal(5, diffs_report.new_violations_size)
28+
assert_equal(6, diffs_report.violation_diffs_size)
29+
30+
assert_equal(1, diffs_report.removed_violations_size)
31+
assert_equal(4, diffs_report.new_violations_size)
32+
assert_equal(1, diffs_report.changed_violations_size)
33+
3134
assert_equal('Base1.java', keys[0])
3235
assert_equal('SameFileNameWithDiffViolations.java', keys[1])
33-
assert_equal(3, violation_diffs[keys[1]].size)
36+
assert_equal(2, violation_diffs[keys[1]].size)
3437
assert_equal('Patch1.java', keys[2])
3538
assert_equal('Patch2.java', keys[3])
3639
assert_equal('Patch3.java', keys[4])

0 commit comments

Comments
 (0)