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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With