How can I disable a specific type of missing comment warning in Javadoc?

Viewed 167

I'm using javadoc through Gradle and since upgrading to Java 18, javadoc reports following warning:

warning: use of default constructor, which does not provide a comment

I would like this warning message to be disabled so that I can check for the completeness of javadoc comments in my project by looking at the number of reported warnings. In general, missing doc comments can be disabled with the -Xdoclint:all,-missing argument but this is too coarse as in my understanding it disables all missing comment warnings. Warnings that comments are missing on default constructors are not interesting or helpful to me so I would like to disable them specifically.

Further information: The JDK commit that introduced the checking of missing comments on default constructors specifies the missing-type dc.default.constructor but I haven't been able to find a way of using this.

1 Answers

Unfortunately, this is not possible. -Xdoclint only provides the missing key, with no more fine-grained control.

If you want more fine-grained control, you can use the require-javadoc program instead of -Xdoclint:missing. require-javadoc never requires comments on a default constructor, which does not appear in source code. Its configuration includes the following command-line options:

  --exclude=<regex>                - Don't check files or directories whose pathname matches the regex
  --dont-require=<regex>           - Don't report problems in Java elements whose name matches the regex
  --dont-require-private=<boolean> - Don't report problems in elements with private access [default: false]
  --dont-require-noarg-constructor=<boolean> - Don't report problems in constructors with zero formal params [default: false]
  --dont-require-trivial-properties=<boolean> - Don't report problems about trivial getters and setters [default: false]
  --dont-require-type=<boolean>    - Don't report problems in type declarations [default: false]
  --dont-require-field=<boolean>   - Don't report problems in fields [default: false]
  --dont-require-method=<boolean>  - Don't report problems in methods and constructors [default: false]
  --require-package-info=<boolean> - Require package-info.java file to exist [default: false]
  --relative=<boolean>             - Report relative rather than absolute filenames [default: false]
  --verbose=<boolean>              - Print diagnostic information [default: false]

Note, however, that require-javadoc never warns about missing Javadoc tags such as @param and @return.

Related