【发布时间】:2020-11-18 23:10:05
【问题描述】:
我有一个包含数百个包的项目。它主要是从 COBOL 到内联 java 的转换中生成的代码,所以其中绝大多数(约 11,000 个文件)是我不想在其上运行 checkstyle 的。我在项目中有几个包是“真正的”java,我添加了这些包来替换无法通过代码转换生成的实用程序,我确实想在这些包上运行 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* 包中的任何内容进行所有检查。为了查看我的规则是否正在运行,我在文件中添加了第一行,我认为这会抑制对所有文件的所有检查。
这些过滤器都没有抑制任何东西。 Checkstyle 检查所有包中的所有文件(并报告超过 400,000 次违规,对于我关心的人来说,这有点太多了!哈哈)
大多数项目都是基础的,所以我之前使用过没有抑制的 checkstyle。这是我第一次尝试限制代码审查的范围,但并没有像我希望的那样进行。我不确定我的问题出在哪里。
非常感谢任何建议。
【问题讨论】:
-
嗯.. 嗯...我现在正在检查一些东西。我原以为它会跳过文件,但看起来它会拿起文件然后跳过检查。我;验证后更新