} else if (alertLevel.equals(Metric.Level.WARN)) {
valueToEval = alert.getValueWarning();
+
} else {
throw new IllegalStateException(alertLevel.toString());
}
+
if (StringUtils.isEmpty(valueToEval)) {
return false;
}
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)
+ );
}
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));
}
}
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);
}
}
}
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;
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;
}
}
- } catch (Exception e) {
+ } catch (IOException e) {
// silently ignore
} finally {
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 {
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;