Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavadocMethod accessModifiers incorrectly interpreted for interface class #10835

Closed
ladislavlencucha opened this issue Sep 29, 2021 · 3 comments · Fixed by #10840
Closed

JavadocMethod accessModifiers incorrectly interpreted for interface class #10835

ladislavlencucha opened this issue Sep 29, 2021 · 3 comments · Fixed by #10840
Milestone

Comments

@ladislavlencucha
Copy link

ladislavlencucha commented Sep 29, 2021

I have read check documentation: https://checkstyle.org/config_javadoc.html#JavadocMethod
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

/var/tmp $ javac YOUR_FILE.java
#[[MAKE SURE THERE IS SUCCESSFUL COMPILATION]]
public interface MyInterface {
  /** Javadoc ok here. */
  void test();

  class MyClass {
    /** Missing parameter here. */
    public MyClass(Integer amount) {
    }
  }
}

/var/tmp $ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
  <property name="charset" value="UTF-8"/>
  <property name="fileExtensions" value="java, xml, properties"/>
  <module name="TreeWalker">
    <module name="JavadocMethod">
      <property name="accessModifiers" value="public"/>
      <property name="allowMissingParamTags" value="false"/>
      <property name="allowMissingReturnTag" value="true"/>
    </module>  
  </module>
</module>

/var/tmp $ cat YOUR_FILE.java
#[[PLACE YOU OUTPUT HERE]]

/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-9.0-all.jar -c config.xml YOUR_FILE.java
Starting audit...
Audit done.

I expect checkstyle to report constructor to have missing javadoc param. Reason for that is that interface of this inner class is implicitly considered public according to java specs (Some IDEs even mark explicit public keyword as unnecessary).
If I add public keyword to class declaration, constructor is reported by checkstyle as expected.

@pbludov
Copy link
Member

pbludov commented Oct 1, 2021

Similar to Issue #9876
The problem is here:

        // default access modifier
        AccessModifierOption accessModifier = AccessModifierOption.PACKAGE;

The default access modifier is not package in Java. The surrounding scope should be checked. Something like that.

@Vyom-Yadav
Copy link
Member

on it

Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 2, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 2, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 5, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 10, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 12, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 15, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 15, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 15, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 17, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 21, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 24, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 24, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Oct 27, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Nov 7, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Nov 7, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Nov 7, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Nov 7, 2021
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Nov 7, 2021
@romani romani added this to the 9.2 milestone Nov 11, 2021
@romani
Copy link
Member

romani commented Nov 11, 2021

fix is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants