Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all Classes WITHOUT Javadocs

Tags:

java

javadoc

Is there any simple way to analyze source code to list the number of classes that don't have any javadocs?

As part of a technical debt exercise I want to list all these files and share the list out among the team to have the original authors write them.

Note: We are using gradle as build system

UPDATE... So empty javadocs get created by default but our devs havnt filled them in much. Id like to be able to see all classes that dont have any description in the doc at class level. I dont mind about methods too much.

like image 487
Rob McFeely Avatar asked Aug 26 '15 14:08

Rob McFeely


People also ask

Do private methods need JavaDoc?

Nope, you shouldn't write javadoc for private methods. End users don't have access to private fields or methods so there really isn't a point in providing javadoc for them. Private fields and methods are only meant for the developer. If you really need to though, feel free to write comments for non-obvious logic.

What are javadocs and when should they be used?

JavaDoc tool is a document generator tool in Java programming language for generating standard documentation in HTML format. It generates API documentation. It parses the declarations ad documentation in a set of source file describing classes, methods, constructors, and fields.

What does class <?> Mean in Java?

What Does Class Mean? A class — in the context of Java — is a template used to create objects and to define object data types and methods. Classes are categories, and objects are items within each category. All class objects should have the basic class properties.

What does @SEE mean in JavaDoc?

In short, we use the @see tag when we want a link or a text entry that points to a reference. This tag adds a “See Also” heading to the reference. A document comment can hold any number of @see tags, all of which can be grouped under the same heading.


1 Answers

An easy way would be to use Checkstyle.

Download the jar file and create a config XML file (javadoc_checks.xml) like this:

<module name="Checker">
    <module name="TreeWalker">
        <module name="JavadocType"/>
        <module name="JavadocMethod"/>
        <module name="JavadocVariable"/>
        <module name="JavadocStyle"/>
    </module>
</module>

Now run the following command (assuming everything is in the same directory and src contains your code):

java -jar checkstyle-6.9-all.jar -c javadoc_checks.xml src/

If, for example, you just want to check for missing javadocs for classes and interfaces, then you just need this in the config XML:

<module name="Checker">
    <module name="TreeWalker">
        <module name="JavadocType"/>
    </module>
</module>

And the output would be something like:

C:\src\com\example\Test.java:137: Javadoc comment missing.
C:\src\com\example\Test1.java:3: Javadoc comment missing.
C:\src\com\example\Test2.java:12: Javadoc comment missing.

There are a lot of options, you can see them in:

http://checkstyle.sourceforge.net/config_javadoc.html

http://checkstyle.sourceforge.net/cmdline.html

like image 97
Esteban Herrera Avatar answered Oct 11 '22 07:10

Esteban Herrera