SONAR-75 fix loading of checkstyle bundles

This commit is contained in:
Simon Brandhof 2011-07-26 16:01:55 +02:00
parent 99dd166d42
commit fea2ef37ed
2 changed files with 8 additions and 8 deletions

View File

@ -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 {

View File

@ -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