1

I have a legacy java application where many javadocs are duplicated or just the empty template of a method javadoc is present.

I would like to use a tool to clean up those empty and superfluous JavaDoc comment.

Here is an example for a better understanding. Same Problem exists for inherited methods of course.

public interface BaseIfc {

    /**
     * This is the javadoc comment written in the interface.
     * @param myParameter the parameter description
     * @return the return value description
     * @throws Exception definition of the exception
     */
    public int myInterfaceMethod(final String myParameter) throws Exception;

    /**
     * Another javadoc comment in the interface
     * @param myClass the myClass parameter
     * @return the return value description
     */
    public String myOtherInterfaceMethod(final Class myClass);
}

Here is a class implementing this interface and doing wrong things with the JavaDoc:

public class BaseClass implements BaseIfc {
    // same javadoc as in BaseIfc, should be removed
    /**
     * This is the javadoc comment written in the interface.
     * @param myParameter the parameter description
     * @return the return value description
     * @throws Exception definition of the exception
     */
    @Override
    public int myInterfaceMethod(String myParameter) throws Exception {
        return 0;
    }

    // different javadoc should stay
    /**
     * Own javadoc !
     * @param myClass special information for parameter
     */
    public String myOtherInterfaceMethod(Class myClass) {
        return null;
    }

    // this is just the javadoc template with no information so should be removed
    /**
     * 
     * @param myIntParam
     * @return
     * @throws Exception
     */
    private String ownUndocumentedMethod(int myIntParam) throws Exception {
        return "";
    }

    // complete empty blocks should be removed as well 
    /**
     * 
     * 
     * 
     */
    private int anotherUndocumentedMethod( int myIntParam ) {
        return 0;
    }
}

I am using maven and eclipse, but any tool or hint / help is appreciated.
Thanks a lot in advance.

Matze
  • 93
  • 2
  • 10
  • I would go for a custom java implem, reading files of your choices, writing bytes one after one, whenever you find ```/**``` you go to silent mode, and when finding ```*/``` you go back to normal mode. Feel free to implement the rule of the complexity you want (looking to the related interface to see if we are really in silent mode). I'm not aware of any tooling that may help, however, less than one hour of coding should do the job. – spi Dec 08 '17 at 12:26
  • 1
    Maybe https://stackoverflow.com/questions/9078528/tool-to-remove-javadoc-comments can help? – Ralf Renz Dec 08 '17 at 12:29

0 Answers0