aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2012-12-06 16:15:10 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2012-12-06 16:15:10 +0100
commitf09252799644be3b7bb3a852b926386df0c24936 (patch)
treea68e4929d71a041e3b45a9f53d1df38ef932f10b /plugins
parent94b2f5e6468d8cd82d85d61c6c0f8d50374b797a (diff)
downloadsonarqube-f09252799644be3b7bb3a852b926386df0c24936.tar.gz
sonarqube-f09252799644be3b7bb3a852b926386df0c24936.zip
Fix some quality flaws
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java15
1 files changed, 9 insertions, 6 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 5d5e6c89a2c..95951013333 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
@@ -52,16 +52,19 @@ public final class AlertUtils {
Comparable criteriaValue = getValueForComparison(alert.getMetric(), valueToEval);
Comparable measureValue = getMeasureValue(alert, measure);
if (measureValue != null) {
- int comparison = measureValue.compareTo(criteriaValue);
- return !(// NOSONAR complexity of this boolean expression is under control
- (alert.isNotEqualsOperator() && comparison == 0)
- || (alert.isGreaterOperator() && comparison != 1)
- || (alert.isSmallerOperator() && comparison != -1)
- || (alert.isEqualsOperator() && comparison != 0));
+ return doesReachThresholds(measureValue, criteriaValue, alert);
}
return false;
}
+ private static boolean doesReachThresholds(Comparable measureValue, Comparable criteriaValue, Alert alert){
+ int comparison = measureValue.compareTo(criteriaValue);
+ return !((alert.isNotEqualsOperator() && comparison == 0)
+ || (alert.isGreaterOperator() && comparison != 1)
+ || (alert.isSmallerOperator() && comparison != -1)
+ || (alert.isEqualsOperator() && comparison != 0));
+ }
+
private static String getValueToEval(Alert alert, Metric.Level alertLevel) {
if (alertLevel.equals(Metric.Level.ERROR)) {
return alert.getValueError();