简体   繁体   中英

Suppress checkstyle errors on PRIVATE member variables in a suppressions.xml?

On a project I am working on, checkstyle is failing with "Missing a Javadoc comment" due to a missing Javadoc comment on a private member variable. This seems like unnecessarily strict behaviour to me and I would like to suppress the error for private members using a suppressions XML file.

The following file succeeds in suppressing all checkstyle Javadoc errors on variables:

<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
    "-//Puppy Crawl//DTD Suppressions 1.1//EN"
    "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
    <suppress files=".*" checks="JavadocVariable"/>
</suppressions>

However, this is not terribly useful behaviour because I still consider failure to document protected and public members to be an error.

How can I modify the checks attribute to give me the limited suppression I need?

Afaik, this cannot be achieved using suppressions, unless you want to annotate every private field. Instead, configure the JavadocVariable check so that it does not cover private scope:

<module name="JavadocVariable">
   <property name="scope" value="package"/>
</module>

A scope of package means " package or more public".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM