在Eclipe PMD插件中,我可以引用标准规则集文件吗? [英] In the Eclipe PMD plugin, can I reference the standard ruleset files?

查看:191
本文介绍了在Eclipe PMD插件中,我可以引用标准规则集文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的 eclipse PMD插件配置访问相同的标准规则集文件作为 maven-pmd-plugin

I would like my eclipse PMD plugin configuration to access the same standard ruleset files as the maven-pmd-plugin.

您可以配置maven pmd插件以使用自定义一套这样的规则集:

You can configure the maven pmd plugin to use a custom set of rule sets like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>2.5</version>
    <configuration>
      <rulesets>
        <!-- Two rule sets that come bundled with PMD -->
        <ruleset>/rulesets/braces.xml</ruleset>
        <ruleset>/rulesets/naming.xml</ruleset>
        <!-- Custom local file system rule set -->
        <ruleset>d:\rulesets\strings.xml</ruleset>
        <!-- Custom remote rule set accessed via a URL -->
        <ruleset>http://localhost/design.xml</ruleset>
      </rulesets>
    </configuration>
</plugin>

但在eclipse插件中,您只能打开/关闭单个规则或指定一个规则集文件。规则集文件可能包含其他几种方法吗?或者我必须从我想要使用的规则集自动聚合该文件?

but in the eclipse plugin you can only switch on / turn off individual rules or specify a single ruleset file. Is there perhaps a way that ruleset file can include several others? Or do I have to aggregate that file automatically from the rulesets I want to use?

推荐答案

您可以在PMD中包含其他规则集规则集文件,例如

You can include other rulesets in a PMD ruleset file, e.g.

<ruleset ...>
    ...
    <rule ref="rulesets/basic.xml"/>
    ...
    <rule ref="rulesets/strings.xml">
        <exclude name="AvoidDuplicateLiterals"/>
    </rule>
    ...
</ruleset>

这实际上是我们自己的规则集文件的摘录,所以它被证明是有效的: - )

This is actually an excerpt from our own ruleset file, so it is proven to work :-)

如您所见,您可以从规则集中排除/包含单个规则,甚至重新配置它们。一个警告:您不得在单一规则集中混合不同语言的规则。即在我们的例子中,我们必须为Java和JSP创建单独的规则集。

As you can see, you can exclude/include individual rules from your ruleset, or even reconfigure them. One caveat: you must not mix rules for different languages in a single ruleset. I.e. in our case, we had to create separate rulesets for Java and JSP.

我从此页面

这篇关于在Eclipe PMD插件中,我可以引用标准规则集文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆