From: David Gageot Date: Fri, 6 Jul 2012 11:39:45 +0000 (+0200) Subject: SONAR-1995 Use TEXT input for xpath expression in XPath Rule X-Git-Tag: 3.2~204 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d4fe52e57da960412135997a10a875a009af4a75;p=sonarqube.git SONAR-1995 Use TEXT input for xpath expression in XPath Rule --- 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 @@ MULTIPLE - + 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; @@ -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() { + 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 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 = {})