eclipse中的PMD不接受排除模式

问题描述 投票:5回答:2

我在eclipse 4.3.1 / Kepler下使用PMD,我不能从违规检查中排除文件和文件夹。

我的文件夹结构

/any/path/to/the/workspace/myproject1
/any/path/to/the/workspace/myproject2
/any/path/to/the/workspace/myprojectWithPMDrulesFile/pmd-rules.xml

现在,以下文件夹由testng生成

...../myproject1/test-output
...../myproject2/test-output

现在我配置了以下规则文件:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     name="Xeno-PMD-rules"
     xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
    <description>PMD Plugin preferences rule set</description>
    <exclude-pattern>.*/test-output/*.*</exclude-pattern>
    <exclude-pattern>/.*/test-output/.*</exclude-pattern>
    <exclude-pattern>**/test-output/**</exclude-pattern>
    <exclude-pattern>./test-output/.</exclude-pattern>
    <rule ref="rulesets/java/android.xml/CallSuperFirst"/>
    ...
</ruleset>

在我的情况下,我在jquery.js文件中有很多错误,它在测试输出中。

如何以递归方式排除特定文件夹及其中的所有文件?

如何设置模式在eclipse和ANT / maven下工作?

提示:似乎类似于:PMD exclude not working

eclipse pmd
2个回答
8
投票

你几乎已经拥有它了!使用以下排除语法:

<exclude-pattern>.*/test-output/.*</exclude-pattern>

这将排除在绝对路径中某处具有/test-output/的所有文件。 Eclipse和Ant / Maven中的模式相同,只要排除的文件夹也称为test-output

其他解释和示例可以在PMD documentation中找到。


0
投票

您可以在项目 - >属性 - > PMD下指定工作集

© www.soinside.com 2019 - 2024. All rights reserved.