diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-26 16:01:55 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-26 16:01:55 +0200 |
commit | fea2ef37ed0a1dfa73ebdd87799f5caa298aa2f2 (patch) | |
tree | d5c3824189d60c9e1cd122c9e55a96b065b8445d | |
parent | 99dd166d42bb8ba8ff49b01599339bcb10bd241b (diff) | |
download | sonarqube-fea2ef37ed0a1dfa73ebdd87799f5caa298aa2f2.tar.gz sonarqube-fea2ef37ed0a1dfa73ebdd87799f5caa298aa2f2.zip |
SONAR-75 fix loading of checkstyle bundles
-rw-r--r-- | plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java | 11 | ||||
-rw-r--r-- | plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java | 5 |
2 files changed, 8 insertions, 8 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java index 518a169bb4c..b3cd4db85ac 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/i18n/I18nManager.java @@ -230,15 +230,14 @@ public final class I18nManager implements I18n, ServerExtension { return localeToUse; } - protected String extractRuleName(String ruleDescriptionKey) { - int firstDotIndex = ruleDescriptionKey.indexOf("."); - int secondDotIndex = ruleDescriptionKey.indexOf(".", firstDotIndex + 1); - int thirdDotIndex = ruleDescriptionKey.indexOf(".", secondDotIndex + 1); - return ruleDescriptionKey.substring(secondDotIndex + 1, thirdDotIndex); + String extractRuleKeyFromDescriptionProperty(String ruleDescriptionKey) { + // format is "rule.<plugin>.<key>.description" + String s = StringUtils.substringAfter(ruleDescriptionKey, "rule."); + return StringUtils.substringBetween(s, ".", ".description"); } protected String computeHtmlFilePath(String bundleBaseName, String ruleDescriptionKey, Locale locale) { - String ruleName = extractRuleName(ruleDescriptionKey); + String ruleName = extractRuleKeyFromDescriptionProperty(ruleDescriptionKey); if (Locale.ENGLISH.equals(locale)) { return bundleBaseName + "/" + ruleName + ".html"; } else { diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java index 4a09e952479..66c8ad17a31 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/i18n/I18nManagerTest.java @@ -117,8 +117,9 @@ public class I18nManagerTest { } @Test - public void testExtractRuleName() throws Exception { - assertThat(manager.extractRuleName("rule.squid.ArchitecturalConstraint.description"), is("ArchitecturalConstraint")); + public void shouldExtractRuleKey() throws Exception { + assertThat(manager.extractRuleKeyFromDescriptionProperty("rule.squid.ArchitecturalConstraint.description"), is("ArchitecturalConstraint")); + assertThat(manager.extractRuleKeyFromDescriptionProperty("rule.checkstyle.com.puppycrawl.checkstyle.IllegalRegexp.description"), is("com.puppycrawl.checkstyle.IllegalRegexp")); } @Test |