aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-21 16:23:13 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-05-21 16:23:33 +0200
commit6d3dfbc0ec43edcb6b8d37ca822641c9865297b8 (patch)
treebb518e65debeff5bf4c3dc63a1d9615816c9aec9 /sonar-plugin-api
parent90620b8f68670a8ba72ee2cf8ab795fe6e271ef8 (diff)
downloadsonarqube-6d3dfbc0ec43edcb6b8d37ca822641c9865297b8.tar.gz
sonarqube-6d3dfbc0ec43edcb6b8d37ca822641c9865297b8.zip
Fix quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java36
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java29
2 files changed, 31 insertions, 34 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
index b755da6f5b5..e4bc8948523 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
@@ -20,15 +20,6 @@
package org.sonar.api.batch.rule;
import com.google.common.collect.Maps;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.AnnotationUtils;
-import org.sonar.api.utils.FieldUtils2;
-import org.sonar.api.utils.SonarException;
-import org.sonar.check.RuleProperty;
-
-import javax.annotation.CheckForNull;
-
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
@@ -36,6 +27,13 @@ import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.rule.RuleKey;
+import org.sonar.api.utils.AnnotationUtils;
+import org.sonar.api.utils.FieldUtils2;
+import org.sonar.api.utils.SonarException;
+import org.sonar.check.RuleProperty;
/**
* Instantiates checks (objects that provide implementation of coding
@@ -199,34 +197,34 @@ public class Checks<C> {
if (field.getType().equals(String.class)) {
field.set(check, value);
- } else if ("int".equals(field.getType().getSimpleName())) {
+ } else if (int.class == field.getType()) {
field.setInt(check, Integer.parseInt(value));
- } else if ("short".equals(field.getType().getSimpleName())) {
+ } else if (short.class == field.getType()) {
field.setShort(check, Short.parseShort(value));
- } else if ("long".equals(field.getType().getSimpleName())) {
+ } else if (long.class == field.getType()) {
field.setLong(check, Long.parseLong(value));
- } else if ("double".equals(field.getType().getSimpleName())) {
+ } else if (double.class == field.getType()) {
field.setDouble(check, Double.parseDouble(value));
- } else if ("boolean".equals(field.getType().getSimpleName())) {
+ } else if (boolean.class == field.getType()) {
field.setBoolean(check, Boolean.parseBoolean(value));
- } else if ("byte".equals(field.getType().getSimpleName())) {
+ } else if (byte.class == field.getType()) {
field.setByte(check, Byte.parseByte(value));
- } else if (field.getType().equals(Integer.class)) {
+ } else if (Integer.class == field.getType()) {
field.set(check, Integer.parseInt(value));
- } else if (field.getType().equals(Long.class)) {
+ } else if (Long.class == field.getType()) {
field.set(check, Long.parseLong(value));
- } else if (field.getType().equals(Double.class)) {
+ } else if (Double.class == field.getType()) {
field.set(check, Double.parseDouble(value));
- } else if (field.getType().equals(Boolean.class)) {
+ } else if (Boolean.class == field.getType()) {
field.set(check, Boolean.parseBoolean(value));
} else {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java
index 1629acf498f..d68197ff6dd 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java
@@ -20,6 +20,10 @@
package org.sonar.api.checks;
import com.google.common.collect.Maps;
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.rule.Checks;
import org.sonar.api.profiles.RulesProfile;
@@ -31,11 +35,6 @@ import org.sonar.api.utils.SonarException;
import org.sonar.check.Rule;
import org.sonar.check.RuleProperty;
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
/**
* @since 2.3
* @deprecated since 4.2 use {@link Checks}
@@ -112,34 +111,34 @@ public final class AnnotationCheckFactory extends CheckFactory {
if (field.getType().equals(String.class)) {
field.set(check, value);
- } else if ("int".equals(field.getType().getSimpleName())) {
+ } else if (int.class == field.getType()) {
field.setInt(check, Integer.parseInt(value));
- } else if ("short".equals(field.getType().getSimpleName())) {
+ } else if (short.class == field.getType()) {
field.setShort(check, Short.parseShort(value));
- } else if ("long".equals(field.getType().getSimpleName())) {
+ } else if (long.class == field.getType()) {
field.setLong(check, Long.parseLong(value));
- } else if ("double".equals(field.getType().getSimpleName())) {
+ } else if (double.class == field.getType()) {
field.setDouble(check, Double.parseDouble(value));
- } else if ("boolean".equals(field.getType().getSimpleName())) {
+ } else if (boolean.class == field.getType()) {
field.setBoolean(check, Boolean.parseBoolean(value));
- } else if ("byte".equals(field.getType().getSimpleName())) {
+ } else if (byte.class == field.getType()) {
field.setByte(check, Byte.parseByte(value));
- } else if (field.getType().equals(Integer.class)) {
+ } else if (Integer.class == field.getType()) {
field.set(check, Integer.parseInt(value));
- } else if (field.getType().equals(Long.class)) {
+ } else if (Long.class == field.getType()) {
field.set(check, Long.parseLong(value));
- } else if (field.getType().equals(Double.class)) {
+ } else if (Double.class == field.getType()) {
field.set(check, Double.parseDouble(value));
- } else if (field.getType().equals(Boolean.class)) {
+ } else if (Boolean.class == field.getType()) {
field.set(check, Boolean.parseBoolean(value));
} else {