diff options
author | fmallet <freddy.mallet@gmail.com> | 2010-09-15 22:01:00 +0000 |
---|---|---|
committer | fmallet <freddy.mallet@gmail.com> | 2010-09-15 22:01:00 +0000 |
commit | f27104c1d98ac616ba1c91c3cfe96e0e495b725a (patch) | |
tree | 371c7f3c40eb1629956a91fdfa1002133ba60969 /plugins/sonar-pmd-plugin/src/main | |
parent | 513e60ec6d331bd8554326425fb3f401eeb6b2a9 (diff) | |
download | sonarqube-f27104c1d98ac616ba1c91c3cfe96e0e495b725a.tar.gz sonarqube-f27104c1d98ac616ba1c91c3cfe96e0e495b725a.zip |
fix SONAR-1766 - A warning is generated when the user tries to import a PMD configuration file with contains XPath rules. Those rules must be defined through the user web interface.
Diffstat (limited to 'plugins/sonar-pmd-plugin/src/main')
-rw-r--r-- | plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdProfileImporter.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdProfileImporter.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdProfileImporter.java index 21f3968d9ea..85ad6321f71 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdProfileImporter.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdProfileImporter.java @@ -58,6 +58,16 @@ public class PmdProfileImporter extends ProfileImporter { protected RulesProfile createRuleProfile(PmdRuleset pmdRuleset, ValidationMessages messages) { RulesProfile profile = RulesProfile.create(); for (PmdRule pmdRule : pmdRuleset.getPmdRules()) { + if (PmdConstants.XPATH_CLASS.equals(pmdRule.getClazz())) { + messages.addWarningText("PMD XPath rule '" + pmdRule.getName() + + "' can't be imported automatically. The rule must be created manually through the Sonar web interface."); + continue; + } + if (pmdRule.getRef() == null) { + messages.addWarningText("A PMD rule without 'ref' attribute can't be imported. see '" + pmdRule.getClazz() + + "'"); + continue; + } Rule rule = ruleFinder.find(RuleQuery.create().withRepositoryKey(PmdConstants.REPOSITORY_KEY).withConfigKey(pmdRule.getRef())); if (rule != null) { ActiveRule activeRule = profile.activateRule(rule, PmdLevelUtils.fromLevel(pmdRule.getPriority())); @@ -86,6 +96,9 @@ public class PmdProfileImporter extends ProfileImporter { PmdRuleset pmdResultset = new PmdRuleset(); for (Element eltRule : getChildren(eltResultset, "rule", namespace)) { PmdRule pmdRule = new PmdRule(eltRule.getAttributeValue("ref")); + pmdRule.setClazz(eltRule.getAttributeValue("class")); + pmdRule.setName(eltRule.getAttributeValue("name")); + pmdRule.setMessage(eltRule.getAttributeValue("message")); parsePmdPriority(eltRule, pmdRule, namespace); parsePmdProperties(eltRule, pmdRule, namespace); pmdResultset.addRule(pmdRule); |