aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-07-06 13:39:45 +0200
committerDavid Gageot <david@gageot.net>2012-07-06 13:39:45 +0200
commitd4fe52e57da960412135997a10a875a009af4a75 (patch)
treed9e23b3bf0cae4410ead00bfbd9b1652a9a92eb6
parent35ac8c8e18298c50898805e6610ddeddb9f3e173 (diff)
downloadsonarqube-d4fe52e57da960412135997a10a875a009af4a75.tar.gz
sonarqube-d4fe52e57da960412135997a10a875a009af4a75.zip
SONAR-1995 Use TEXT input for xpath expression in XPath Rule
-rw-r--r--plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml2
-rw-r--r--plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb6
3 files changed, 18 insertions, 4 deletions
diff --git a/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml b/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
index 961239cadef..3bea66d4808 100644
--- a/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
+++ b/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
@@ -1814,7 +1814,7 @@
<cardinality>MULTIPLE</cardinality>
- <param key="xpath" type="s">
+ <param key="xpath" type="TEXT">
</param>
<param key="message" type="s">
diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java
index 036f5b48743..30113aa0764 100644
--- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java
+++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdRuleRepositoryTest.java
@@ -19,8 +19,11 @@
*/
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;
@@ -77,6 +80,17 @@ public class PmdRuleRepositoryTest {
}
@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);
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb
index 9919f45db5d..b3ea8ddf3a5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/rules_configuration_helper.rb
@@ -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 = {})