From checkstyle/checkstyle-openrewrite-recipes#123
Description
When a Checkstyle module is configured with a custom id, the XML output shows only the ID in the source attribute. This makes it impossible to know which actual check raised the violation.
Example Configuration
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- Instance WITHOUT ID -->
<module name="NewlineAtEndOfFile"/>
<!-- Instance WITH ID -->
<module name="NewlineAtEndOfFile">
<property name="id" value="twCheck"/>
</module>
</module>
Test.java
checkstyle/autofix/recipe ❯ cat Test.java java 06:34
package org.checkstyle.autofix.recipe;
public class Test {
}
Output
checkstyle/autofix/recipe ❯javaa -jarcheckstyle-12.1.2-all.jarr \ java 06:22
-c config.xml \
-f xml \
Test.java
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="12.1.2">
<file name="/home/tomato/MINE/checkstyle-openrewrite-recipes/src/main/java/org/checkstyle/autofix/recipe/Test.java">
<error line="1" severity="error" message="File does not end with a newline." source="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck"/>
<error line="1" severity="error" message="File does not end with a newline." source="twCheck"/>
</file>
</checkstyle>
Checkstyle ends with 2 errors.
Problem
When id is used, the source attribute becomes ambiguous: source="twCheck"
There is no way to know which check this refers to.
Tools consuming XML cannot map violations back to their actual modules.
SARIF already solves this problem by using: source="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck#twCheck"
From checkstyle/checkstyle-openrewrite-recipes#123
Description
When a Checkstyle module is configured with a custom
id, the XML output shows only the ID in thesourceattribute. This makes it impossible to know which actual check raised the violation.Example Configuration
Test.java
checkstyle/autofix/recipe ❯ cat Test.java java 06:34 package org.checkstyle.autofix.recipe; public class Test { }Output
Problem
When id is used, the source attribute becomes ambiguous:
source="twCheck"There is no way to know which check this refers to.
Tools consuming XML cannot map violations back to their actual modules.
SARIF already solves this problem by using:
source="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck#twCheck"