aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2012-12-10 15:25:31 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2012-12-10 15:25:44 +0100
commit8fa017822aedda6928f7886a20832c9dc225d11e (patch)
treec0ecf07f0fbdd095a913b5c4f7281bb5ac32e015 /plugins
parentb21329e5860391c8f4b3ac33d878f3af3ad99a6b (diff)
downloadsonarqube-8fa017822aedda6928f7886a20832c9dc225d11e.tar.gz
sonarqube-8fa017822aedda6928f7886a20832c9dc225d11e.zip
Decreased complexity
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java
index 5fbd604e235..d56f275ffc4 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java
@@ -96,7 +96,7 @@ public final class AlertUtils {
return Double.parseDouble(value);
}
if (isAInteger(metric)) {
- return value.contains(".") ? Integer.parseInt(value.substring(0, value.indexOf('.'))) : Integer.parseInt(value);
+ return parseInteger(value);
}
if (isAString(metric)) {
return value;
@@ -107,14 +107,17 @@ public final class AlertUtils {
throw new NotImplementedException(metric.getType().toString());
}
+ private static Comparable<?> parseInteger(String value){
+ return value.contains(".") ? Integer.parseInt(value.substring(0, value.indexOf('.'))) : Integer.parseInt(value);
+ }
+
private static Comparable<?> getMeasureValue(Alert alert, Measure measure) {
Metric metric = alert.getMetric();
if (isADouble(metric)) {
return getValue(alert, measure);
}
if (isAInteger(metric)) {
- Double value = getValue(alert, measure);
- return value != null ? value.intValue() : null;
+ parseInteger(alert, measure);
}
if (alert.getPeriod() == null) {
if (isAString(metric)) {
@@ -127,6 +130,11 @@ public final class AlertUtils {
throw new NotImplementedException(metric.getType().toString());
}
+ private static Comparable<?> parseInteger(Alert alert, Measure measure){
+ Double value = getValue(alert, measure);
+ return value != null ? value.intValue() : null;
+ }
+
private static boolean isADouble(Metric metric){
return metric.getType() == Metric.ValueType.FLOAT ||
metric.getType() == Metric.ValueType.PERCENT ||