问题
I'm trying to create a quality profile in Sonar 3.0.1 and to specify my pmd configuration file. But when I submit it, I've got the following error :
A PMD rule without 'ref' attribute can't be imported. see 'null'
Here the content of my extension file (sample taken at Sonar site) :
<rules>
<rule key="AvoidIfWithoutBrace">
<name>Avoid if without using brace</name>
<configKey>rulesets/extensions.xml/AvoidIfWithoutBrace</configKey>
<category name="Usability" />
<description>éviter les if sans crochet.</description>
</rule>
</rules>
Despite my search, I didn't find the reason of this error.
Thanks for your help.
回答1:
You're mixing concepts.
If you create a profile from the Web UI (see the documentation), then you need to specify a PMD file, i.e. a file with the PMD format that looks like this:
<ruleset>
<rule ref="rulesets/design.xml/SingularField">
<priority>4</priority>
</rule>
...
</ruleset>
What you're currently giving to Sonar is a file with the Sonar format (which is the format that you can use to backup/restore full quality profiles).
来源:https://stackoverflow.com/questions/10997231/why-a-pmd-rule-without-ref-attribute-cant-be-imported-see-null