#614 Add "Single Property Comment" option to JavadocMethod

incomplete (2)
Ryan Baker

Creating Javadoc for Properties is valuable, but if done by any existing rules would result in a great deal of duplication. AllowMissingPropertyJavadoc allows to complete ignore all properties, but a more ideal solution is one in which you only need one comment to cover the getter and setter, and that the getter does not require a @return tag nor the setter an @param tag.

At the base a property is a singular item, and sensibly only requires explanation once. Comments like "Sets myProperty" are useless cruft and best avoided, and copying the whole explanation of what a property is into four places is almost as bad.

While a full implementation would probably involve cross-checking between getter/setter's for existence, a reasonable compromise would be to simply never require a comment for any setter's, and disable @return requirements for the setter.

The setter requirement could be implemented in isMissingJavadocAllowed, something like this:

protected boolean isMissingJavadocAllowed(final DetailAST aAST) {
  return mAllowMissingJavadoc || isOverrideMethod(aAST) || 
    || (mOneJavadocPerProperty && isSetterMethod(aAST))
    || (mAllowMissingPropertyJavadoc && (isGetterMethod(aAST) || isSetterMethod(aAST)));

Changing the return tag would require passing aAST into checkReturnTag:

private void checkReturnTag(List<JavadocTag> aTags, DetailAST aAST, int aLineNo, boolean aReportExpectedTags) {
  // Loop over tags finding return tags. After the first one, report an
  // error.
  boolean found = false;
  final ListIterator<JavadocTag> it = aTags.listIterator();
  while (it.hasNext()) {
    final JavadocTag jt = it.next();
    if (jt.isReturnTag()) {
      if (found) {
        log(jt.getLineNo(), jt.getColumnNo(), "javadoc.duplicateTag", JavadocTagInfo.RETURN.getText());
      found = true;

  // Handle there being no @return tags :- unless
  // the user has chosen to suppress these problems
  if (!found && !mAllowMissingReturnTag && !(mOneJavadocPerProperty && isGetterMethod(aAST)) && aReportExpectedTags) {
    log(aLineNo, "javadoc.return.expected");


  • Ryan Baker
    Ryan Baker

    Should have said at end of third paragraph:

    " and disable @return requirements for the getter."

  • Roman Ivanov
    Roman Ivanov

    • labels: --> incomplete
  • Ivan Sopov
    Ivan Sopov

    • status: open --> closed