Description
Checkstyle allows configuring the same check multiple times with different IDs and configurations. For example:
<module name="TreeWalker">
<!-- Strict check for production code -->
<module name="FinalLocalVariableCheck">
<property name="id" value="strict"/>
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>
<!-- Lenient check for test code -->
<module name="FinalLocalVariableCheck">
<property name="id" value="lenient"/>
<property name="validateEnhancedForLoopVariable" value="false"/>
</module>
</module>
Current Behavior
- Maps checks by their
CheckstyleCheck enum value (class name only), ignoring the id attribute
- Overwrites previous configurations when multiple instances of the same check exist
- Groups all violations from the same check type together, regardless of which check instance reported them
This means violations from strict and lenient are:
- Treated as the same check
- Fixed using only the last loaded configuration
- Cannot be distinguished or fixed differently
Expected Behavior
- Preserve the
id attribute for each check instance
- Store multiple configurations for the same check type (keyed by ID)
- Match violations to their specific check instance using the
id from the report
- Apply the correct configuration when fixing violations from each instance
Starting Point
- Change
CheckstyleCheck enum or create a new identity class that includes both check type and ID
- Update
ConfigurationLoader to preserve multiple instances with their IDs
- Update parsers (XML/SARIF) to extract the check ID from violation reports
- Update
CheckstyleRecipeRegistry to match violations to the correct check instance
Description
Checkstyle allows configuring the same check multiple times with different IDs and configurations. For example:
Current Behavior
CheckstyleCheckenum value (class name only), ignoring theidattributeThis means violations from
strictandlenientare:Expected Behavior
idattribute for each check instanceidfrom the reportStarting Point
CheckstyleCheckenum or create a new identity class that includes both check type and IDConfigurationLoaderto preserve multiple instances with their IDsCheckstyleRecipeRegistryto match violations to the correct check instance