Why : A PMD rule without 'ref' attribute can't be imported. see 'null'?

风流意气都作罢 提交于 2019-12-11 16:52:36

问题


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

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