I noticed that the Javadoc check does not correctly validate @param tags for record components.
Currently, it treats a tag as valid if it shares a prefix with the component name, instead of requiring an exact match. This leads to inconsistent validation results.
Steps to reproduce
- Create a file with the following content:
/**
* Example case
*
* @param john123 wrong tag for a different component
*/
record Sample(String john) {}
- Use the following Checkstyle configuration:
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocType"/>
</module>
</module>
- Run Checkstyle:
checkstyle -c checkstyle.xml Sample.java
Expected behavior
@param tags should match the record component name exactly
- A missing
@param john violation should be reported
Actual behavior
@param john123 is treated as documenting john due to prefix-based matching
- Missing
@param john is not reported
john123 is still flagged as an unused tag
Why this is a problem
This creates inconsistent behavior:
- The incorrect tag is accepted in one place
- But rejected in another
This makes the validation confusing and unreliable.
I noticed that the Javadoc check does not correctly validate
@paramtags for record components.Currently, it treats a tag as valid if it shares a prefix with the component name, instead of requiring an exact match. This leads to inconsistent validation results.
Steps to reproduce
Expected behavior
@paramtags should match the record component name exactly@param johnviolation should be reportedActual behavior
@param john123is treated as documentingjohndue to prefix-based matching@param johnis not reportedjohn123is still flagged as an unused tagWhy this is a problem
This creates inconsistent behavior:
This makes the validation confusing and unreliable.