aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-19 00:02:04 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-19 00:02:58 +0200
commit1f231f2cfcd47e66ca818cd1a8cbd93cc89af45d (patch)
tree0b8ffad8066e9dd1e45b4a872e7b246ade7b3ce9
parent18a85015feb7a27bee89bcfda4421b92f0a9b8c7 (diff)
downloadsonarqube-1f231f2cfcd47e66ca818cd1a8cbd93cc89af45d.tar.gz
sonarqube-1f231f2cfcd47e66ca818cd1a8cbd93cc89af45d.zip
SONAR-5417 Fix manual measures
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java6
3 files changed, 14 insertions, 2 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
index 704a917aece..21193575608 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
@@ -19,6 +19,9 @@
*/
package org.sonar.batch.protocol.input;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
public class Metric {
private final int id;
@@ -31,7 +34,7 @@ public class Metric {
private final boolean optimizedBestValue;
- public Metric(int id, String key, String valueType, Double bestValue, boolean optimizedBestValue) {
+ public Metric(int id, String key, String valueType, @Nullable Double bestValue, boolean optimizedBestValue) {
this.id = id;
this.key = key;
this.valueType = valueType;
@@ -51,6 +54,7 @@ public class Metric {
return valueType;
}
+ @CheckForNull
public Double bestValue() {
return bestValue;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
index 8467e5573d6..d0ada6e8b3c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/referential/DefaultProjectReferentialsLoader.java
@@ -71,7 +71,9 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad
public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) {
ProjectReferentials ref = new ProjectReferentials();
for (Metric m : sessionFactory.getSession().getResults(Metric.class, ENABLED, true)) {
- ref.metrics().add(new org.sonar.batch.protocol.input.Metric(m.getId(), m.getKey(), m.getType().name(), m.getBestValue(), m.isOptimizedBestValue()));
+ Boolean optimizedBestValue = m.isOptimizedBestValue();
+ ref.metrics().add(
+ new org.sonar.batch.protocol.input.Metric(m.getId(), m.getKey(), m.getType().name(), m.getBestValue(), optimizedBestValue != null ? optimizedBestValue : false));
}
String defaultName = settings.getString(ModuleQProfiles.SONAR_PROFILE_PROP);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
index a7bd3164bea..93f874c8af7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
@@ -26,6 +26,7 @@ import org.sonar.api.BatchExtension;
import org.sonar.api.ServerExtension;
import org.sonar.api.batch.InstantiationStrategy;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -466,6 +467,7 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt
return worstValue;
}
+ @CheckForNull
public Double getBestValue() {
return bestValue;
}
@@ -519,6 +521,10 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt
return this;
}
+ /**
+ * @return null for manual metrics
+ */
+ @CheckForNull
public Boolean isOptimizedBestValue() {
return optimizedBestValue;
}