配置 eclipse 插件 PMD 以使用多个规则集

发布于 2024-10-06 20:41:14 字数 324 浏览 0 评论 0原文

我发现 PMD 非常有用的工具。所以我安装了 PMD eclipse 插件。

使用PMD,我们可以定义多个规则集文件。我有多个规则集文件的原因之一是我需要从某些规则中排除某些类,这些规则是命名规则,但不是全部。我通过在单独的规则集文件中定义这些规则并使用元素来实现这一点。就 ant 构建而言,这很好。但是,我想对 PMD eclipse 插件使用相同的规则集文件,以确保使用 ant 或 eclipse 执行 PMD 生成相同的结果。

我没有看到为 PMD eclipse 插件选择多个规则集文件的选项。有没有办法选择多个规则集文件或任何其他替代方案?

请帮忙。

谢谢

I find PMD very useful tool. So I have installed PMD eclipse plugin.

With PMD, we can define multiple ruleset files. One of the reason I have multiple rulesets file is that I need to exclude some classes from some rules say naming rules but not all. I achieved this by defined those rules in a separate ruleset file and using element. This is fine as far ant build is concerned. However, I would like to use the same ruleset files for PMD eclipse plugins to ensure that executing PMD using ant or eclipse generates same result.

I do not see an option to select multiple ruleset files for PMD eclipse plugin. Is there a way to select multiple ruleset files or any other alternative?

Please help.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

鱼忆七猫命九 2024-10-13 20:41:14

规则集引用规则和内置规则集 - 它也可以引用自定义规则集。只需为 basic-ruleset.xml 和 codesize-ruleset.xml 创建一个wrapper-ruleset.xml:

<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="pmd-eclipse" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
    <rule ref="basic-ruleset.xml"/>
    <rule ref="codesize-ruleset.xml"/>
</ruleset>

然后您就可以在 Eclipse 中使用wrapper-ruleset.xml。

A rulesets references rules and built-in rulesets - and it can reference custom rulesets too. Just create a wrapper-ruleset.xml for basic-ruleset.xml and codesize-ruleset.xml:

<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="pmd-eclipse" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
    <rule ref="basic-ruleset.xml"/>
    <rule ref="codesize-ruleset.xml"/>
</ruleset>

You can then use wrapper-ruleset.xml in Eclipse.

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