PMD in eclipse does not accept exclude-pattern

匿名 (未验证) 提交于 2019-12-03 03:10:03

问题:

I am using PMD under eclipse 4.3.1 / Kepler and I cannot exclude files and folders from the violation check.

My folder structure

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

Now following folders get generated by testng

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

Now I have configured following rules file:

<?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> 

In my case I have many hundred errors in the jquery.js file, which is in test-output.

How can I exclude a specific folder and all files in it recursively?

How to set the pattern to work under eclipse and under ANT/maven?

hint: seems to be similar to: PMD exclude not working

回答1:

You almost got it already! Use the following exclusion syntax:

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

This will exclude all files that have /test-output/ somewhere in their absolute path. The pattern is the same in Eclipse and Ant/Maven, as long as the excluded folders are also called test-output.

Additional explanations and examples can be found in the PMD documentation.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!