javadoc-coverage icon indicating copy to clipboard operation
javadoc-coverage copied to clipboard

Spot useless javadocs

Open manoelcampos opened this issue 6 years ago • 0 comments

Sometimes, developers write useless javadocs such as the example below

/**
 * Some Foo Method.
 * @param id the id
 * @return 
*/
int someFooMethod(int id){ return 0; }

The plugin should spot this kind of "documentation" and present them into the report. A common pattern to detect such useless javadocs are:

  • the method documentation includes only the name of the method, accordingly separating words by space
  • param documentation just includes the name or type of the param, preceded by an article (the, a, an): the id, an id, an int
  • method or param documentation includes just one word.
  • after removing connectors (the, a, and, of, to, for, etc) and spaces from the documentation, the text remaining is equal to the element name, for instance:
/**
 * Compute the statistics.
*/
double computeStatistics(){ return 0; }

However, it may be difficult to detect verbs in the 3rd person of the singular, such as "Computes" instead of "Compute".

Regular expressions should be defined to detect such issues. A set of regex should be defined by default, but the plugin should enable developers to specify their own regex and if they want to use both the given regular expressions and the standard ones, or just the given ones.

manoelcampos avatar Jul 19 '17 10:07 manoelcampos