Can't import PMD Ruleset in Eclipse

Lionel Père picture Lionel Père · Apr 5, 2013 · Viewed 13.7k times · Source

I would like to use the same Ruleset in my IDE (Eclipse) that my Sonar profile.

I got the PMD XML ruleset from the Sonar Permalinks and would like to import it into my PMD Eclipse Plugin but when i try to do it, the "OK" button is desactivated ...

Can't import a PMD Ruleset in PMD Eclipse Plugin

Can someone help me ?

Answer

Ivan Nikolov picture Ivan Nikolov · Jun 5, 2013

The problem could be that Sonar is exporting your ruleset for v4.x format and your Eclipse plugin expects them in v5.x format.

Try changing your rules from:

<rule ref="rulesets/basic.xml/UnusedNullCheckInEquals">
    <priority>3</priority>
</rule>

to

<rule ref="rulesets/java/basic.xml/UnusedNullCheckInEquals">
    <priority>3</priority>
</rule>

Please note the ref attribute. A simple find and replace all will work out fine for you.