禁用特定 java 包的所有 checkstyle 检查
我有两个包,即
com/mydomain/abc/delegate/xyz/jaxws/托管
和 com/mydomain/abc/xyz/jaxws/management
我要求仅对第二个包禁用 checkstyle,因为它们包含的代理类是自动生成的。
我使用如下所示的suppression.xml
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"suppressions_1_1.dtd">
<suppressions>
<!-- Suppress JavadocPackage in the test packages -->
<suppress checks="JavadocPackage" files="[\\/]test[\\/]"/>
<!-- Suppress all checkstyle for autogenerated jaxws.managed package -->
<suppress checks="[a-zA-Z0-9]*" files="([^(delegate)])+([a-z]*[\\/]jaxws[\\/]managed[\\/])+"/>
</suppressions>
请注意,用于禁用JavadocPackage 检查的第一个抑制工作正常,但第二个则不然。我担心我选择包的正则表达式可能是错误的。非常感谢任何帮助。
举个例子说明一下我的需求:
选择的标准是包名以jaxws.management
结尾,但包名中不应该包含delegate
。更多关于delegate
应该出现在包名称中的jaxws.management
之前:
例如:checktyle检查包com.mycomany.delegate.service.jaxws.management 必须启用,而
com.mycompany.abc.service.jaxws.service
中的必须禁用,并且需要注意的是,除了这个模式之外,我不知道所有的 pakages 名称。
感谢和问候 西比
I have two packages namely
com/mydomain/abc/delegate/xyz/jaxws/managed
and com/mydomain/abc/xyz/jaxws/managed
I require checkstyle to be disabled only for the second package as these holds proxy classes that are autogenerated.
I use a suppression.xml as shown below
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"suppressions_1_1.dtd">
<suppressions>
<!-- Suppress JavadocPackage in the test packages -->
<suppress checks="JavadocPackage" files="[\\/]test[\\/]"/>
<!-- Suppress all checkstyle for autogenerated jaxws.managed package -->
<suppress checks="[a-zA-Z0-9]*" files="([^(delegate)])+([a-z]*[\\/]jaxws[\\/]managed[\\/])+"/>
</suppressions>
Please note the first suppression for disabling JavadocPackage check works fine but the second one does not. I am afraid that my regex for selecting the package might be wrong. Any help is much appreciated.
To state my requirements with an example:
The criteria for selection is that the package name should end in jaxws.managed
but should not contain delegate
in package name. More over delegate
should come before jaxws.managed
in the package name:
eg: checktyle checks in package com.mycomany.delegate.service.jaxws.managed
must be enabled while that in com.mycompany.abc.service.jaxws.service
must be disabled and it is to be noted that I do not know all the pakages names upfront except for this pattern.
Thanks and Regards
Sibi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需使用抑制:
或者,我建议仅将要检查的文件传递给 Checkstyle。例如,如果您使用 ANT,请使用 a 指定要处理的文件,并使用 指定要忽略的文件。
例如:
Just use the suppression:
Alternatively, I would recommend only passing the files you want checked to Checkstyle. For example, if you are using ANT, use a to specify the files to process, and use to specify files to ignore.
For example:
(?! 委托 \b) [\/][az]*[\/]jaxws[\/]托管[\/]
(?! delegate \b) [\/][a-z]*[\/]jaxws[\/]managed[\/]