diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-02 18:18:07 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-02 18:18:07 +0200 |
commit | 1f5682409af97410aca5e545ccbd40b6b037e6a9 (patch) | |
tree | ba9f1fe3c26d994b9aaafe9a09d5cf528fc21a41 /sonar-core | |
parent | 6e38de82d91aed63e200f0b45f54a4a2a7875941 (diff) | |
download | sonarqube-1f5682409af97410aca5e545ccbd40b6b037e6a9.tar.gz sonarqube-1f5682409af97410aca5e545ccbd40b6b037e6a9.zip |
Fix new violations
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java | 2 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java | 34 |
2 files changed, 22 insertions, 14 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java index 9004a699a9f..9421f31da8d 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18nManager.java @@ -36,7 +36,7 @@ import java.text.MessageFormat; import java.util.*; public class I18nManager implements I18n, ServerExtension { - private static Logger LOG = LoggerFactory.getLogger(I18nManager.class); + private static final Logger LOG = LoggerFactory.getLogger(I18nManager.class); public static final String ENGLISH_PACK_PLUGIN_KEY = "l10nen"; public static final String BUNDLE_PACKAGE = "org.sonar.l10n."; diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java index 6d681196c28..da1a374329a 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java @@ -28,6 +28,9 @@ import java.util.Locale; public class RuleI18nManager implements ServerComponent { + private static final String NAME_SUFFIX = ".name"; + private static final String RULE_PREFIX = "rule."; + private I18nManager i18nManager; private RuleKey[] ruleKeys; @@ -46,11 +49,11 @@ public class RuleI18nManager implements ServerComponent { } public String getName(String repositoryKey, String ruleKey, Locale locale) { - return message(repositoryKey, ruleKey, locale, ".name"); + return message(repositoryKey, ruleKey, locale, NAME_SUFFIX); } public String getDescription(String repositoryKey, String ruleKey, Locale locale) { - String relatedProperty = new StringBuilder().append("rule.").append(repositoryKey).append(".").append(ruleKey).append(".name").toString(); + String relatedProperty = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(ruleKey).append(NAME_SUFFIX).toString(); // TODO add cache String description = i18nManager.messageFromFile(locale, ruleKey + ".html", relatedProperty); @@ -65,7 +68,7 @@ public class RuleI18nManager implements ServerComponent { } String message(String repositoryKey, String ruleKey, Locale locale, String suffix) { - String propertyKey = new StringBuilder().append("rule.").append(repositoryKey).append(".").append(ruleKey).append(suffix).toString(); + String propertyKey = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(ruleKey).append(suffix).toString(); return i18nManager.message(locale, propertyKey, null); } @@ -85,14 +88,14 @@ public class RuleI18nManager implements ServerComponent { } static RuleKey extractRuleKey(String propertyKey) { - String s = StringUtils.substringBetween(propertyKey, "rule.", ".name"); + String s = StringUtils.substringBetween(propertyKey, RULE_PREFIX, NAME_SUFFIX); String ruleKey = StringUtils.substringAfter(s, "."); String repository = StringUtils.substringBefore(s, "."); return new RuleKey(repository, ruleKey); } static boolean isRuleProperty(String propertyKey) { - return StringUtils.startsWith(propertyKey, "rule.") && StringUtils.endsWith(propertyKey, ".name") && propertyKey.indexOf(".param.") < 0; + return StringUtils.startsWith(propertyKey, RULE_PREFIX) && StringUtils.endsWith(propertyKey, NAME_SUFFIX) && propertyKey.indexOf(".param.") < 0; } public static class RuleKey { @@ -113,19 +116,24 @@ public class RuleI18nManager implements ServerComponent { } public String getNameProperty() { - return new StringBuilder().append("rule.").append(repositoryKey).append(".").append(key).append(".name").toString(); + return new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(key).append(NAME_SUFFIX).toString(); } @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } RuleKey ruleKey = (RuleKey) o; - - if (!key.equals(ruleKey.key)) return false; - if (!repositoryKey.equals(ruleKey.repositoryKey)) return false; - + if (!key.equals(ruleKey.key)) { + return false; + } + if (!repositoryKey.equals(ruleKey.repositoryKey)) { + return false; + } return true; } |