diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-30 16:52:26 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-30 17:14:22 +0200 |
commit | c95a564cd7ee1705f38062efe4f8750dffd6a8fa (patch) | |
tree | e94a9567229aac0ec664254c802365f9deac72c8 /sonar-batch/src | |
parent | d44ef046f3dd7d59397c681cb79ebe3173d915bb (diff) | |
download | sonarqube-c95a564cd7ee1705f38062efe4f8750dffd6a8fa.tar.gz sonarqube-c95a564cd7ee1705f38062efe4f8750dffd6a8fa.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-batch/src')
3 files changed, 33 insertions, 21 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java index 0391110d3a5..f7acd618a3a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java @@ -30,6 +30,10 @@ import java.util.Collection; import java.util.List; public class BatchComponents { + private BatchComponents() { + // only static stuff + } + public static Collection all() { List components = Lists.newArrayList( // Maven diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index a9224cbbf3e..0ec11fc5973 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -60,14 +60,14 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio private <T> List<T> getFilteredExtensions(Class<T> type, @Nullable Project project, @Nullable ExtensionMatcher matcher) { List<T> result = Lists.newArrayList(); for (Object extension : getExtensions(type)) { - if (type == Sensor.class && extension instanceof Analyzer) { + if (Sensor.class.equals(type) && extension instanceof Analyzer) { extension = new SensorWrapper((Analyzer) extension, context, analyzerOptimizer); } if (shouldKeep(type, extension, project, matcher)) { result.add((T) extension); } } - if (type == Sensor.class) { + if (Sensor.class.equals(type)) { // Retrieve Analyzer and wrap then in SensorWrapper for (Object extension : getExtensions(Analyzer.class)) { extension = new SensorWrapper((Analyzer) extension, context, analyzerOptimizer); @@ -81,7 +81,7 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio private boolean shouldKeep(Class type, Object extension, @Nullable Project project, @Nullable ExtensionMatcher matcher) { boolean keep = (ClassUtils.isAssignable(extension.getClass(), type) - || (type == Sensor.class && ClassUtils.isAssignable(extension.getClass(), Analyzer.class))) + || (Sensor.class.equals(type) && ClassUtils.isAssignable(extension.getClass(), Analyzer.class))) && (matcher == null || matcher.accept(extension)); if (keep && project != null && ClassUtils.isAssignable(extension.getClass(), CheckProject.class)) { keep = ((CheckProject) extension).shouldExecuteOnProject(project); diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java index 59b3209dfef..5d5378a638a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java +++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java @@ -60,9 +60,9 @@ class ConditionUtils { private static boolean doesReachThresholds(Comparable measureValue, Comparable criteriaValue, ResolvedCondition condition) { int comparison = measureValue.compareTo(criteriaValue); return !(isNotEquals(comparison, condition) - || isGreater(comparison, condition) - || isSmaller(comparison, condition) - || isEquals(comparison, condition)); + || isGreater(comparison, condition) + || isSmaller(comparison, condition) + || isEquals(comparison, condition)); } private static boolean isNotEquals(int comparison, ResolvedCondition condition) { @@ -156,18 +156,18 @@ class ConditionUtils { private static boolean isADouble(Metric metric) { return metric.getType() == Metric.ValueType.FLOAT || - metric.getType() == Metric.ValueType.PERCENT || - metric.getType() == Metric.ValueType.RATING; + metric.getType() == Metric.ValueType.PERCENT || + metric.getType() == Metric.ValueType.RATING; } private static boolean isAInteger(Metric metric) { return metric.getType() == Metric.ValueType.INT || - metric.getType() == Metric.ValueType.MILLISEC; + metric.getType() == Metric.ValueType.MILLISEC; } private static boolean isAString(Metric metric) { return metric.getType() == Metric.ValueType.STRING || - metric.getType() == Metric.ValueType.LEVEL; + metric.getType() == Metric.ValueType.LEVEL; } private static boolean isABoolean(Metric metric) { @@ -183,18 +183,26 @@ class ConditionUtils { Double value; if (period == null) { value = measure.getValue(); - } else if (period == 1) { - value = measure.getVariation1(); - } else if (period == 2) { - value = measure.getVariation2(); - } else if (period == 3) { - value = measure.getVariation3(); - } else if (period == 4) { - value = measure.getVariation4(); - } else if (period == 5) { - value = measure.getVariation5(); } else { - throw new IllegalStateException("Following index period is not allowed : " + Double.toString(period)); + switch (period.intValue()) { + case 1: + value = measure.getVariation1(); + break; + case 2: + value = measure.getVariation2(); + break; + case 3: + value = measure.getVariation3(); + break; + case 4: + value = measure.getVariation4(); + break; + case 5: + value = measure.getVariation5(); + break; + default: + throw new IllegalStateException("Following index period is not allowed : " + Double.toString(period)); + } } return value; } |