Identified at #12151 (comment)
Whenever verifyFilterWithInlineConfigParser() is called, it creates a list of violationsWithoutFilters, sorts it and passes it onto verifyViolations()
|
Collections.sort(violationsWithoutFilters); |
|
verifyViolations(configWithoutFilters, filePath, violationsWithoutFilters); |
The way those violationsWithoutFilters(TestInputViolation objects) are sorted is by line number:
|
public int compareTo(TestInputViolation testInputViolation) { |
|
return Integer.compare(lineNo, testInputViolation.lineNo); |
|
} |
verifyViolations() compares that sorted list against actualViolations
|
final List<String> actualViolations = getActualViolationsForFile(config, file); |
|
for (int index = 0; index < actualViolations.size(); index++) { |
|
assertWithMessage("Actual and expected violations differ.") |
|
.that(actualViolations.get(index)) |
|
.matches(testInputViolations.get(index).toRegex()); |
This created an issue at #12151 (comment) when there are 2 or more violations per line. See how the violations on line 33 are not matching:


A temporary hack was implemented at #12151 in SuppressWithNearbyTextFilterTest to make testNearbyTextPattern pass by sorting actualViolations before the assertion happens. This hack should be removed after this issue is resolved.
Identified at #12151 (comment)
Whenever
verifyFilterWithInlineConfigParser()is called, it creates a list ofviolationsWithoutFilters, sorts it and passes it ontoverifyViolations()checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java
Lines 212 to 213 in fe36c48
The way those
violationsWithoutFilters(TestInputViolationobjects) are sorted is by line number:checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/bdd/TestInputViolation.java
Lines 89 to 91 in fe36c48
verifyViolations()compares that sorted list againstactualViolationscheckstyle/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java
Line 426 in fe36c48
checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java
Lines 437 to 440 in fe36c48
This created an issue at #12151 (comment) when there are 2 or more violations per line. See how the violations on line


33are not matching:A temporary hack was implemented at #12151 in
SuppressWithNearbyTextFilterTestto maketestNearbyTextPatternpass by sortingactualViolationsbefore the assertion happens. This hack should be removed after this issue is resolved.