如何在Checkstyle中禁止对文件进行所有检查? [英] How to suppress all checks for a file in Checkstyle?
问题描述
我正在对第三方类进行覆盖,我想要取消对它的所有检查(因为我只保留它直到接受补丁)。
I'm doing an override for a third party class and I want to suppress all checks for it (since I'm only keeping it around until the patch is accepted).
有没有办法抑制文件的所有检查?
Is there a way to suppress all checks for a file?
我尝试使用*但失败了。
I tried using "*" but that fails.
推荐答案
不知道你是在使用命令行还是在IDE中,但你是' ll基本上需要一个suppresions文件。如果您手动编辑Checkstyle配置文件,请向其添加一个新模块:
Don't know whether you're using command line or in an IDE, but you'll basically need a suppresions file. If you're manually editing the Checkstyle config file, add a new module to it:
<module name="SuppressionFilter">
<property name="file" value="mysuppressions.xml" />
</module>
你的 mysuppression.xml
可以像:
<?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="TheClassToIgnore\.java" checks="[a-zA-Z0-9]*"/>
</suppressions>
files
属性的值是基本上是源文件的正则表达式,检查
属性的值是正则表示要跳过哪些检查( [a-zA- Z0-9] *
基本上是指跳过所有内容。这是你想要的模式吗?
The value for "files
" attribute is basically a regex for your source files, and the value for the "checks
" attribute is regex for what checks to skip ("[a-zA-Z0-9]*
" basically means skip everything). This is the pattern you're looking for I guess?
这篇关于如何在Checkstyle中禁止对文件进行所有检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!