]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1995 Use TEXT input for xpath expression in XPath Rule
authorDavid Gageot <david@gageot.net>
Fri, 6 Jul 2012 11:39:45 +0000 (13:39 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 6 Jul 2012 11:39:45 +0000 (13:39 +0200)
plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java
sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb

index 961239cadef7f222d4c08cafb89cb2b5e6656650..3bea66d480868507c6da453d69ed79f887f9d61b 100644 (file)
 
     <cardinality>MULTIPLE</cardinality>
 
-    <param key="xpath" type="s">
+    <param key="xpath" type="TEXT">
 
     </param>
     <param key="message" type="s">
index 036f5b487434a283c77108836b5f4d797729d465..30113aa0764502cdf51f013bd9aba741efc84ed7 100644 (file)
  */
 package org.sonar.plugins.pmd;
 
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 import org.junit.Before;
 import org.junit.Test;
+import org.sonar.api.PropertyType;
 import org.sonar.api.platform.ServerFileSystem;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.XMLRuleParser;
@@ -76,6 +79,17 @@ public class PmdRuleRepositoryTest {
     assertThat(rules).onProperty("key").excludes("JUnitStaticSuite");
   }
 
+  @Test
+  public void should_use_text_parameter_for_xpath_rule() {
+    Rule xpathRule = Iterables.find(repository.createRules(), new Predicate<Rule>() {
+      public boolean apply(Rule rule) {
+        return rule.getKey().equals("XPathRule");
+      }
+    });
+
+    assertThat(xpathRule.getParam("xpath").getType()).isEqualTo(PropertyType.TEXT.name());
+  }
+
   @Test
   public void should_provide_a_name_and_description_for_each_rule() {
     List<Rule> rules = RuleRepositoryTestHelper.createRulesWithNameAndDescription("pmd", repository);
index 9919f45db5de5dc40e3dd26f8a125a99e1824be6..b3ea8ddf3a56b8e6cb6f20fbe3c286008f841d82 100644 (file)
@@ -34,18 +34,18 @@ module RulesConfigurationHelper
     return PropertyType::TYPE_INTEGER if type == PARAM_TYPE_INTEGER_LIST
     return PropertyType::TYPE_BOOLEAN if type == PARAM_TYPE_BOOLEAN
     return PropertyType::TYPE_STRING if type == PARAM_TYPE_REGEXP
+    return PropertyType::TYPE_STRING if is_set(type)
 
-    PropertyType::TYPE_STRING
+    type
   end
 
   def readable_type(type)
-    return "" if type == PARAM_TYPE_STRING
     return "Set of string (, as delimiter)" if type == PARAM_TYPE_STRING_LIST
     return "Number" if type == PARAM_TYPE_INTEGER
     return "Set of number (, as delimiter)" if type == PARAM_TYPE_INTEGER_LIST
-    return "" if type == PARAM_TYPE_BOOLEAN
     return "Regular expression" if type == PARAM_TYPE_REGEXP
     return "Set of values (, as delimiter)" if is_set(type)
+    ""
   end
 
   def param_value_input(parameter, value, options = {})