Checkstyle - 排除文件夹

Phi*_*der 20 eclipse checkstyle

我想忽略我的checkstyle报告中的特定文件夹(名为generated-sources),因为它们是生成的.

我正在使用eclipse-cs来显示我的违规行为.

我在我的xml中添加了一个suppressfilter:

<module name="SuppressionFilter">
    <property name="file" value=".\suppressions.xml"/>
</module>
Run Code Online (Sandbox Code Playgroud)

我的suppressions.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="\*generated-sources\*\*\.\*" checks="[a-zA-Z0-9]*"/>
</suppressions>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.有任何想法吗?

Phi*_*der 30

<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
Run Code Online (Sandbox Code Playgroud)

这工作:)

  • 诀窍是Checkstyle将正则表达式应用于*文件路径*,而不是二进制类名称等.你可以将`checks`属性缩短为`checks ="."`. (8认同)