Show warning if method description is missing

11,726

Solution 1

We use this for javadocs in checkstyle:

<module name="JavadocStyle">
    <property name="severity" value="warning"/
    <property name="checkEmptyJavadoc" value="true"/>
</module>

As you see checkEmptyJavadoc should help you.

Solution 2

It may be too late for this post - but anyone else looking to find answer, add description to each element e.g.

/**
 * @param tagID - ID of the tag
 * @param startDate - Starting Date
 * @param endDate - End date
 * @param estimated <-- this is not the param - should be removed or fix doc
 * @return <-- missing return param and description
 * @throws ServerException -- throws server exception
 */
Share:
11,726
Jatin
Author by

Jatin

http://jatinpuri.com

Updated on July 05, 2022

Comments

  • Jatin
    Jatin almost 2 years

    In our code base, i see a lot of methods like there:

    /**
         * @param tagID
         * @param startDate
         * @param endDate
         * @param estimated
         * @return
         * @throws ServerException
         */
        List<String> generateMaster(int tagID, Date date)
                throws ServerException, BusinessException;
    

    Though there is a javadoc present, the description of method is missing. Hence the javadoc is plainly useless. In checkstyle, what do i do so that it gives a warning for above cases.

    <property name="allowMissingJavadoc" value="false"/>
    

    This only checks if at all there is a javadoc present or not. It marks the above method as present as the javadoc is present. But the method declaration is actually missing.

    PS: Tagging eclipse and intellij. I am happy with any solution which tells me the number of methods containing above like javadocs