Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable checkstyle JavaDoc validation for constructors?

How to disable checkstyle JavaDoc validation for constructors?

I see that http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod states clearly that it "Checks the Javadoc of a method or constructor", however I need to exclude constructors and leave only methods.

like image 799
Dmitry Avatar asked Aug 31 '15 19:08

Dmitry


People also ask

How do I turn off checkstyle?

Then to disable Checkstyle, you use //CHECKSTYLE:OFF and //CHECKSTYLE:ON (default values) in your code.

What does missing a Javadoc comment mean?

Meaning. On line #1, a Javadoc comment is missing. You need a comment for the class itself. Fix. Add a comment at the top of the class.

How do I create a missing Javadoc in Netbeans?

All you have to do is, while you have a file opened, go to the "Tools" menu, and select "Analyze Javadoc." This opens up an other window that lets you select which methods you would like to generate JavaDoc forms for. Once you select the ones you want to add, click "Fix Selected".

What is a summary Javadoc?

Each Javadoc block begins with a brief summary fragment. This fragment is very important: it is the only part of the text that appears in certain contexts such as class and method indexes. This is a fragment—a noun phrase or verb phrase, not a complete sentence.


1 Answers

In order to ignore constructors, remove the CTOR_DEF token from the tokens property, for example:

<module name="JavadocMethod">
  <property name="tokens" value="METHOD_DEF,ANNOTATION_FIELD_DEF"/>
</module>

This is achieved by setting tokens to all the other allowed tokens except CTOR_DEF. Unfortunately, for this to work, you need to know which tokens to set, and this list varies by Checkstyle version and is not always accurately reflected in the docs. This above example should provide a reasonable setting.

like image 155
barfuin Avatar answered Sep 21 '22 06:09

barfuin