aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java/org/sonar/api/profiles
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-04-24 10:12:28 +0200
committerDavid Gageot <david@gageot.net>2012-04-27 14:58:59 +0200
commit872b3923f80d9a2bcc13713f41cf801f2a7024eb (patch)
tree2ef0a5003c3becb1b0e53d5683e60ed3c9f759b5 /sonar-plugin-api/src/main/java/org/sonar/api/profiles
parent4b262d15878b31c6c2c7efd8236fb5c65093ba11 (diff)
downloadsonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.tar.gz
sonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.zip
Remove warnings
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/profiles')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java18
2 files changed, 12 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java
index de4d4ec82a4..07dee384d61 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/AnnotationProfileParser.java
@@ -35,7 +35,7 @@ import java.util.Collection;
*/
public final class AnnotationProfileParser implements ServerComponent {
- private RuleFinder ruleFinder;
+ private final RuleFinder ruleFinder;
public AnnotationProfileParser(RuleFinder ruleFinder) {
this.ruleFinder = ruleFinder;
@@ -43,15 +43,15 @@ public final class AnnotationProfileParser implements ServerComponent {
public RulesProfile parse(String repositoryKey, String profileName, String language, Collection<Class> annotatedClasses, ValidationMessages messages) {
RulesProfile profile = RulesProfile.create(profileName, language);
- for (Class aClass : annotatedClasses) {
- BelongsToProfile belongsToProfile = (BelongsToProfile) aClass.getAnnotation(BelongsToProfile.class);
+ for (Class<?> aClass : annotatedClasses) {
+ BelongsToProfile belongsToProfile = aClass.getAnnotation(BelongsToProfile.class);
addRule(aClass, belongsToProfile, profile, repositoryKey, messages);
}
return profile;
}
private void addRule(Class aClass, BelongsToProfile annotation, RulesProfile profile, String repositoryKey, ValidationMessages messages) {
- if (annotation != null && StringUtils.equals(annotation.title(), profile.getName())) {
+ if ((annotation != null) && StringUtils.equals(annotation.title(), profile.getName())) {
String ruleKey = RuleAnnotationUtils.getRuleKey(aClass);
Rule rule = ruleFinder.findByKey(repositoryKey, ruleKey);
if (rule == null) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
index da1ffdf3b47..8c8f876c00b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
@@ -19,10 +19,9 @@
*/
package org.sonar.api.profiles;
+import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.CharEncoding;
import org.apache.commons.lang.StringUtils;
-import org.codehaus.stax2.XMLInputFactory2;
import org.codehaus.staxmate.SMInputFactory;
import org.codehaus.staxmate.in.SMHierarchicCursor;
import org.codehaus.staxmate.in.SMInputCursor;
@@ -36,15 +35,14 @@ import org.sonar.api.rules.RulePriority;
import org.sonar.api.utils.Logs;
import org.sonar.api.utils.ValidationMessages;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
import java.io.InputStreamReader;
import java.io.Reader;
-import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
/**
* TODO should be an interface
*
@@ -52,7 +50,7 @@ import javax.xml.stream.XMLStreamException;
*/
public final class XMLProfileParser implements ServerComponent {
- private RuleFinder ruleFinder;
+ private final RuleFinder ruleFinder;
private MetricFinder metricFinder;
/**
@@ -77,7 +75,7 @@ public final class XMLProfileParser implements ServerComponent {
}
public RulesProfile parseResource(ClassLoader classloader, String xmlClassPath, ValidationMessages messages) {
- Reader reader = new InputStreamReader(classloader.getResourceAsStream(xmlClassPath), Charset.forName(CharEncoding.UTF_8));
+ Reader reader = new InputStreamReader(classloader.getResourceAsStream(xmlClassPath), Charsets.UTF_8);
try {
return parse(reader, messages);
@@ -127,7 +125,7 @@ public final class XMLProfileParser implements ServerComponent {
}
private SMInputFactory initStax() {
- XMLInputFactory xmlFactory = XMLInputFactory2.newInstance();
+ XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
// just so it won't try to load DTD in if there's DOCTYPE
@@ -172,7 +170,7 @@ public final class XMLProfileParser implements ServerComponent {
for (Map.Entry<String, String> entry : parameters.entrySet()) {
if (rule.getParam(entry.getKey()) == null) {
messages.addWarningText("The parameter '" + entry.getKey() + "' does not exist in the rule: [repository=" + repositoryKey
- + ", key=" + key + "]");
+ + ", key=" + key + "]");
} else {
activeRule.setParameter(entry.getKey(), entry.getValue());
}