简体   繁体   English

抑制suppressions.xml中PRIVATE成员变量的checkstyle错误?

[英]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. 在我正在进行的项目中,由于缺少对私有成员变量的Javadoc注释,checkstyle失败了“Missing a Javadoc comment”。 This seems like unnecessarily strict behaviour to me and I would like to suppress the error for private members using a suppressions XML file. 这对我来说似乎是不必要的严格行为,我想使用抑制XML文件来抑制私有成员的错误。

The following file succeeds in suppressing all checkstyle Javadoc errors on variables: 以下文件成功抑制了变量上的所有 checkstyle Javadoc错误:

<?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? 如何修改checks属性以便为我提供有限的抑制?

Afaik, this cannot be achieved using suppressions, unless you want to annotate every private field. Afaik,除非你想要注释每个私有字段,否则无法使用抑制来实现。 Instead, configure the JavadocVariable check so that it does not cover private scope: 而是,配置JavadocVariable检查,以便它不涵盖私有范围:

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

A scope of package means " package or more public". package 范围意味着“ package或更多公共”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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