aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-02-25 18:16:54 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-02-25 18:16:54 +0100
commit0616121414c5962853bccfe75b22805b64424526 (patch)
tree859332d19154a1382984a76ce99b9438bda5c30b /sonar-plugin-api
parent8d36a74954dce0c1e22497b97cee5c0a07f8a291 (diff)
downloadsonarqube-0616121414c5962853bccfe75b22805b64424526.tar.gz
sonarqube-0616121414c5962853bccfe75b22805b64424526.zip
SONAR-2218 add NewCoverageDecorator + add DateUtils to API
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java22
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java28
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java15
3 files changed, 58 insertions, 7 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index e88512934b9..59c1f66ed9a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -224,6 +224,15 @@ public final class CoreMetrics {
public static final Metric LINES_TO_COVER = new Metric(LINES_TO_COVER_KEY, "Lines to cover", "Lines to cover", Metric.ValueType.INT,
Metric.DIRECTION_BETTER, false, DOMAIN_TESTS).setFormula(new SumChildValuesFormula(false)).setHidden(true);
+ public static final String NEW_LINES_TO_COVER_KEY = "new_lines_to_cover";
+ public static final Metric NEW_LINES_TO_COVER = new Metric.Builder(NEW_LINES_TO_COVER_KEY, Metric.ValueType.INT)
+ .setName("New lines to cover")
+ .setDescription("New lines to cover")
+ .setDirection(Metric.DIRECTION_BETTER)
+ .setDomain(DOMAIN_TESTS)
+ .setFormula(new SumChildValuesFormula(false))
+ .setHidden(true)
+ .create();
public static final String UNCOVERED_LINES_KEY = "uncovered_lines";
public static final Metric UNCOVERED_LINES = new Metric.Builder(UNCOVERED_LINES_KEY, Metric.ValueType.INT)
@@ -256,7 +265,15 @@ public final class CoreMetrics {
public static final Metric CONDITIONS_TO_COVER = new Metric.Builder(CONDITIONS_TO_COVER_KEY, Metric.ValueType.INT)
.setName("Conditions to cover")
.setDescription("Conditions to cover")
- .setDirection(Metric.DIRECTION_BETTER)
+ .setDomain(DOMAIN_TESTS)
+ .setFormula(new SumChildValuesFormula(false))
+ .setHidden(true)
+ .create();
+
+ public static final String NEW_CONDITIONS_TO_COVER_KEY = "new_conditions_to_cover";
+ public static final Metric NEW_CONDITIONS_TO_COVER = new Metric.Builder(NEW_CONDITIONS_TO_COVER_KEY, Metric.ValueType.INT)
+ .setName("New conditions to cover")
+ .setDescription("New conditions to cover")
.setDomain(DOMAIN_TESTS)
.setFormula(new SumChildValuesFormula(false))
.setHidden(true)
@@ -565,7 +582,6 @@ public final class CoreMetrics {
Metric.ValueType.INT, Metric.DIRECTION_BETTER, false, DOMAIN_DESIGN).setHidden(true);
-
// Alerts
public static final String ALERT_STATUS_KEY = "alert_status";
public static final Metric ALERT_STATUS = new Metric.Builder(ALERT_STATUS_KEY, Metric.ValueType.LEVEL)
@@ -575,7 +591,7 @@ public final class CoreMetrics {
.setQualitative(true)
.setDomain(DOMAIN_GENERAL)
.create();
-
+
/* quality profile */
public static final String PROFILE_KEY = "profile";
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java
new file mode 100644
index 00000000000..510cb0c0161
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/DateUtils.java
@@ -0,0 +1,28 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.utils;
+
+/**
+ * @since 2.7
+ */
+public interface DateUtils {
+ String DATE_FORMAT = "yyyy-MM-dd";
+ String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
index 8ba231af888..165152c3537 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
@@ -141,10 +141,10 @@ public final class KeyValueFormat {
}
public static class DateConverter extends Converter<Date> {
- private DateFormat dateFormat;
+ private SimpleDateFormat dateFormat;
public DateConverter() {
- this("yyyy-MM-dd");
+ this(DateUtils.DATE_FORMAT);
}
DateConverter(String format) {
@@ -161,14 +161,14 @@ public final class KeyValueFormat {
try {
return StringUtils.isBlank(s) ? null : dateFormat.parse(s);
} catch (ParseException e) {
- throw new SonarException("Not a date: " + s, e);
+ throw new SonarException("Not a date with format: " + dateFormat.toPattern(), e);
}
}
}
public static class DateTimeConverter extends DateConverter {
public DateTimeConverter() {
- super("yyyy-MM-dd'T'HH:mm:ssZ");
+ super(DateUtils.DATETIME_FORMAT);
}
}
@@ -228,6 +228,13 @@ public final class KeyValueFormat {
/**
* @since 2.7
*/
+ public static Map<Integer, Integer> parseIntInt(String data) {
+ return parse(data, IntegerConverter.INSTANCE, IntegerConverter.INSTANCE);
+ }
+
+ /**
+ * @since 2.7
+ */
public static Map<Integer, Date> parseIntDateTime(String data) {
return parse(data, IntegerConverter.INSTANCE, new DateTimeConverter());
}