禁用特定 java 包的所有 checkstyle 检查

发布于 2024-09-28 21:01:33 字数 1226 浏览 6 评论 0原文

我有两个包,即

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野心澎湃 2024-10-05 21:01:33

只需使用抑制:

<suppress checks="." files="com[\\/]mydomain[\\/]abc[\\/]xyz[\\/]jaxws[\\/]managed[\\/]"/>

或者,我建议仅将要检查的文件传递给 Checkstyle。例如,如果您使用 ANT,请使用 a 指定要处理的文件,并使用 指定要忽略的文件。

例如:

<fileset dir="src">
  <include name="**/*.java"/>
  <exclude name="com/mycompany/abc/service/jaxws/service/*.java"/>
</fileset>

Just use the suppression:

<suppress checks="." files="com[\\/]mydomain[\\/]abc[\\/]xyz[\\/]jaxws[\\/]managed[\\/]"/>

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:

<fileset dir="src">
  <include name="**/*.java"/>
  <exclude name="com/mycompany/abc/service/jaxws/service/*.java"/>
</fileset>
夜无邪 2024-10-05 21:01:33

(?! 委托 \b) [\/][az]*[\/]jaxws[\/]托管[\/]

(?! delegate \b) [\/][a-z]*[\/]jaxws[\/]managed[\/]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文