mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-07-28 20:18:04 +02:00
SONAR-75 fix loading of checkstyle bundles
This commit is contained in:
parent
99dd166d42
commit
fea2ef37ed
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user