Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PMD in eclipse does not accept exclude-pattern

Tags:

eclipse

pmd

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

like image 563
hkais Avatar asked Nov 23 '13 13:11

hkais


1 Answers

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.

like image 104
barfuin Avatar answered Sep 21 '22 12:09

barfuin