`JavadocVariable` not considering parent class accessibility when evaluating `accessModifiers`
The issue described in https://github.com/checkstyle/checkstyle/issues/16786 was a regression for enums, but the same scenario exists for other fields:
$ javac Test.java
$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocVariable">
<property name="accessModifiers" value="public"/>
</module>
</module>
</module>
$ cat Test.java
class Test {
public static String str = "";
}
$ java -jar checkstyle-10.24.0-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:2:5: Missing a Javadoc comment. [JavadocVariable]
Audit done.
Checkstyle ends with 1 errors.
[ERROR] MyClass.java:2:5: Missing a Javadoc comment. [JavadocVariable]
str may marked as public, but in reality it's effectively package private due to a package private parent.
Originally raised here
This is a feature request for a change in this behaviour, but in reality such a change would likely require extra customisation options as previously suggested.
ATTENTION: As prove of fix, please send revert for this line https://github.com/hazelcast/hazelcast/commit/c4ed533167f462918ab19ebc2dbdcfeb7bcc1d0b#diff-9ee0c5e88ab0b482432ac7e9107fff6f456f0a60add701bbdd6510310478b7dcR72-R73