#331 JavadocMethod always requires Javadoc

Check (274)
Robert Gardner

I would like to be able to check the @param, @return
tags, etc., on methods that have Javadoc comments
without requiring that the method actually have a
Javadoc comment. In other words, if the Javadoc
comment is missing, do not report a violation. However,
if the Javadoc is there, confirm that the @param,
@return tags, etc., are correct.

This does not seem to be possible. Could a parameter be
added to allow this?


  • Logged In: YES

    Could you, please, explain why do you need such functionality.

  • Robert Gardner
    Robert Gardner

    Logged In: YES

    First, when adopting checkstyle on an existing body of code,
    there will likely be many, many methods that do not have
    javadoc comments. There will also be many methods with
    javadoc comments that are incomplete or with signatures out
    of date with the code. A first step in cleaning up the code
    would be to first make sure that all javadoc comments that
    exist at least present correct signatures. Then as javadoc
    comments are added checkstyle can check that they are
    correct and stay up to date.

    Second, there are a number of methods that just aren't worth
    the effort to comment, especially if you are trying to clean up
    an existing body of code. For example, getters and setters
    are usually self-evident. This is much more true of internal
    code than of code published outside the development team.

    Third, this would make checkstyle consistent with the warning
    settings that Eclipse provides, which allows you to check the
    validity of existing javadoc comments without forcing all
    methods to be commented.

  • Logged In: YES

    Committed changes to CVS for 4.0