将 Checkstyle 限制为某些包
Limiting Checkstyle to certain packages
我有一个包含数百个包的项目。它主要是从 COBOL 到内联 java 的转换生成的代码,所以其中绝大多数(~11,000 个文件)是我不想 运行 checkstyle 的东西。我在项目中确实有几个包是“真实的”java,我添加它们来替换代码转换无法生成的实用程序,我 do 想要运行 checkstyle 在那些。
我无法使抑制正常工作。
这是来自 checkstyle.xml 的相关片段:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/checkstyleSuppress.xml"/>
<property name="optional" value="false"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format"
value="\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message"
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<propert ...
我确信 checkstyleSuppress.xml 文件正在被读取,因为如果我在文件名中添加一个字符使其出错,checkstyle 会出错。
checkstyleSuppress.xml内容如下:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="[/\].+" checks=".*"/>
<suppress checks=".*" files="app[\/]dbio[\/].java"/>
<suppress checks=".*" files="app[\/]dbio[\/]internal[\/].java"/>
<suppress checks=".*" files="app[\/]f17*[\/].java"/>
<suppress checks=".*" files="app[\/]f17*[\/]internal[\/].java"/>
</suppressions>
我想做的是禁止对 app.dbio 和 app.f17* 包中的任何内容进行所有检查。为了查看我的规则是否符合 运行ning,我在文件中添加了第一行,我认为这会禁止对所有文件进行所有检查。
None 这些过滤器正在抑制任何东西。 Checkstyle 检查所有包中的所有文件(并报告超过 400,000 次违规,这对于我关心的那些来说有点太多了!大声笑)
大部分项目都是ground up的,所以我之前都是用checkstyle的,没有压制。这是我第一次尝试限制代码审查的范围,并没有像我希望的那样进行。我不确定我的问题出在哪里。
非常感谢任何建议。
我认为 BeforeExecutionExclusionFileFilter 是您要找的东西。您可以提供匹配您要排除的包的正则表达式,它们将不会被检查。
我有一个包含数百个包的项目。它主要是从 COBOL 到内联 java 的转换生成的代码,所以其中绝大多数(~11,000 个文件)是我不想 运行 checkstyle 的东西。我在项目中确实有几个包是“真实的”java,我添加它们来替换代码转换无法生成的实用程序,我 do 想要运行 checkstyle 在那些。
我无法使抑制正常工作。
这是来自 checkstyle.xml 的相关片段:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the Google coding conventions from Google Java Style
that can be found at https://google.github.io/styleguide/javaguide.html.
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
-->
<module name = "Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/checkstyleSuppress.xml"/>
<property name="optional" value="false"/>
</module>
<module name="TreeWalker">
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
<property name="format"
value="\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\(0(10|11|12|14|15|42|47)|134)"/>
<property name="message"
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
</module>
<module name="AvoidEscapedUnicodeCharacters">
<property name="allowEscapesForControlCharacters" value="true"/>
<propert ...
我确信 checkstyleSuppress.xml 文件正在被读取,因为如果我在文件名中添加一个字符使其出错,checkstyle 会出错。
checkstyleSuppress.xml内容如下:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress files="[/\].+" checks=".*"/>
<suppress checks=".*" files="app[\/]dbio[\/].java"/>
<suppress checks=".*" files="app[\/]dbio[\/]internal[\/].java"/>
<suppress checks=".*" files="app[\/]f17*[\/].java"/>
<suppress checks=".*" files="app[\/]f17*[\/]internal[\/].java"/>
</suppressions>
我想做的是禁止对 app.dbio 和 app.f17* 包中的任何内容进行所有检查。为了查看我的规则是否符合 运行ning,我在文件中添加了第一行,我认为这会禁止对所有文件进行所有检查。
None 这些过滤器正在抑制任何东西。 Checkstyle 检查所有包中的所有文件(并报告超过 400,000 次违规,这对于我关心的那些来说有点太多了!大声笑)
大部分项目都是ground up的,所以我之前都是用checkstyle的,没有压制。这是我第一次尝试限制代码审查的范围,并没有像我希望的那样进行。我不确定我的问题出在哪里。
非常感谢任何建议。
我认为 BeforeExecutionExclusionFileFilter 是您要找的东西。您可以提供匹配您要排除的包的正则表达式,它们将不会被检查。