aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/AlertUtils.java15
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java8
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/VersionEventsSensor.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/License.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/charts/ChartsServlet.java1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java1
7 files changed, 16 insertions, 22 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 5faddcff821..bd1fee2b1e7 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
@@ -49,9 +49,11 @@ public final class AlertUtils {
} else if (alertLevel.equals(Metric.Level.WARN)) {
valueToEval = alert.getValueWarning();
+
} else {
throw new IllegalStateException(alertLevel.toString());
}
+
if (StringUtils.isEmpty(valueToEval)) {
return false;
}
@@ -60,13 +62,12 @@ public final class AlertUtils {
Comparable metricValue = getMeasureValue(alert.getMetric(), measure);
int comparison = metricValue.compareTo(criteriaValue);
- if (alert.isNotEqualsOperator() && comparison == 0 ||
- alert.isGreaterOperator() && comparison != 1 ||
- alert.isSmallerOperator() && comparison != -1 ||
- alert.isEqualsOperator() && comparison != 0) {
- return false;
- }
- return true;
+ 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)
+ );
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java
index 7688f293a2d..fb1f3ef69a1 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/CommentDensityDecorator.java
@@ -61,11 +61,9 @@ public class CommentDensityDecorator implements Decorator {
Measure ncloc = context.getMeasure(CoreMetrics.NCLOC);
Measure comments = context.getMeasure(CoreMetrics.COMMENT_LINES);
- if (MeasureUtils.hasValue(ncloc) && MeasureUtils.hasValue(comments)) {
- if (comments.getValue() + ncloc.getValue() > 0) {
- double val = 100.0 * (comments.getValue() / (comments.getValue() + ncloc.getValue()));
- context.saveMeasure(new Measure(CoreMetrics.COMMENT_LINES_DENSITY, val));
- }
+ if (MeasureUtils.hasValue(ncloc) && MeasureUtils.hasValue(comments) && (comments.getValue() + ncloc.getValue()) > 0) {
+ double val = 100.0 * (comments.getValue() / (comments.getValue() + ncloc.getValue()));
+ context.saveMeasure(new Measure(CoreMetrics.COMMENT_LINES_DENSITY, val));
}
}
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/VersionEventsSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/VersionEventsSensor.java
index e74d012f075..b1fab180258 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/VersionEventsSensor.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/VersionEventsSensor.java
@@ -50,12 +50,9 @@ public class VersionEventsSensor implements Sensor {
String snapshotVersionToDelete = (version.endsWith(SNAPSHOT_SUFFIX) ? "" : version + SNAPSHOT_SUFFIX);
for (Iterator<Event> it = context.getEvents(project).iterator(); it.hasNext();) {
Event event = it.next();
- if (event.isVersionCategory()) {
- if (version.equals(event.getName()) || snapshotVersionToDelete.equals(event.getName())) {
- it.remove();
- context.deleteEvent(event);
- event = null;
- }
+ if (event.isVersionCategory() && (version.equals(event.getName()) || snapshotVersionToDelete.equals(event.getName()))) {
+ it.remove();
+ context.deleteEvent(event);
}
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java
index 5c3bfeaefae..74e1bfe06a4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java
@@ -20,7 +20,6 @@
package org.sonar.api.config;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
index bfc0cab23df..93a22713ead 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
@@ -27,6 +27,7 @@ import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.DateUtils;
import javax.annotation.Nullable;
+import java.io.IOException;
import java.io.StringReader;
import java.util.Calendar;
import java.util.Date;
@@ -112,7 +113,7 @@ public final class License {
}
}
- } catch (Exception e) {
+ } catch (IOException e) {
// silently ignore
} finally {
diff --git a/sonar-server/src/main/java/org/sonar/server/charts/ChartsServlet.java b/sonar-server/src/main/java/org/sonar/server/charts/ChartsServlet.java
index 2a39719585d..77e05930a46 100644
--- a/sonar-server/src/main/java/org/sonar/server/charts/ChartsServlet.java
+++ b/sonar-server/src/main/java/org/sonar/server/charts/ChartsServlet.java
@@ -37,7 +37,6 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Map;
public class ChartsServlet extends HttpServlet {
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
index 51372edf0d5..d5683bddddb 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
@@ -53,7 +53,6 @@ import org.sonar.server.notifications.reviews.ReviewsNotificationManager;
import org.sonar.server.platform.GlobalSettingsUpdater;
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.ServerIdGenerator;
-import org.sonar.server.platform.ServerSettings;
import org.sonar.server.plugins.*;
import org.sonar.server.rules.ProfilesConsole;
import org.sonar.server.rules.RulesConsole;