aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-06-20 17:07:19 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-06-21 00:46:40 +0200
commite6ce2d564b5dd2d5396a8550dfa009e3a5c857a1 (patch)
tree876ac39b67da2ebd840a8cd3a7f561aacb029389 /sonar-plugin-api
parent5de8f9f594279b6bf366e8eb5db63d16f90de800 (diff)
downloadsonarqube-e6ce2d564b5dd2d5396a8550dfa009e3a5c857a1.tar.gz
sonarqube-e6ce2d564b5dd2d5396a8550dfa009e3a5c857a1.zip
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java26
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java5
5 files changed, 28 insertions, 20 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java
index 4f013555766..244d0f93001 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/analyzer/AnalyzerContext.java
@@ -19,8 +19,6 @@
*/
package org.sonar.api.batch.analyzer;
-import org.sonar.api.batch.measure.Metric;
-
import com.google.common.annotations.Beta;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder;
@@ -28,6 +26,7 @@ import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.config.Settings;
@@ -101,7 +100,8 @@ public interface AnalyzerContext {
/**
* Add an issue. Use {@link #issueBuilder()} to create the new issue.
+ * @return true if the new issue is registered, false if the related rule does not exist or is disabled in the Quality profile.
*/
- void addIssue(AnalyzerIssue issue);
+ boolean addIssue(AnalyzerIssue issue);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java
index ab3c359ded8..994eaa78ad0 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/package-info.java
@@ -18,4 +18,5 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.measure; \ No newline at end of file
+package org.sonar.api.batch.measure;
+
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java
index d367aeb4839..7a86f7b145c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java
@@ -170,8 +170,12 @@ public class Measure<G extends Serializable> implements Serializable {
* @param mode the mode
* @return the measure object instance
*/
- public Measure setPersistenceMode(PersistenceMode mode) {
- this.persistenceMode = mode;
+ public Measure setPersistenceMode(@Nullable PersistenceMode mode) {
+ if (mode == null) {
+ this.persistenceMode = PersistenceMode.FULL;
+ } else {
+ this.persistenceMode = mode;
+ }
return this;
}
@@ -408,7 +412,7 @@ public class Measure<G extends Serializable> implements Serializable {
* @param status the status
* @return the measure object instance
*/
- public Measure setAlertStatus(Metric.Level status) {
+ public Measure setAlertStatus(@Nullable Metric.Level status) {
this.alertStatus = status;
return this;
}
@@ -426,7 +430,7 @@ public class Measure<G extends Serializable> implements Serializable {
* @param alertText the text
* @return the measure object instance
*/
- public Measure setAlertText(String alertText) {
+ public Measure setAlertText(@Nullable String alertText) {
this.alertText = alertText;
return this;
}
@@ -446,7 +450,7 @@ public class Measure<G extends Serializable> implements Serializable {
* @param tendency the tendency
* @return the measure object instance
*/
- public Measure setTendency(Integer tendency) {
+ public Measure setTendency(@Nullable Integer tendency) {
this.tendency = tendency;
return this;
}
@@ -473,7 +477,7 @@ public class Measure<G extends Serializable> implements Serializable {
*
* @since 2.5
*/
- public Measure setVariation1(Double d) {
+ public Measure setVariation1(@Nullable Double d) {
this.variation1 = d;
return this;
}
@@ -491,7 +495,7 @@ public class Measure<G extends Serializable> implements Serializable {
*
* @since 2.5
*/
- public Measure setVariation2(Double d) {
+ public Measure setVariation2(@Nullable Double d) {
this.variation2 = d;
return this;
}
@@ -509,7 +513,7 @@ public class Measure<G extends Serializable> implements Serializable {
*
* @since 2.5
*/
- public Measure setVariation3(Double d) {
+ public Measure setVariation3(@Nullable Double d) {
this.variation3 = d;
return this;
}
@@ -527,7 +531,7 @@ public class Measure<G extends Serializable> implements Serializable {
*
* @since 2.5
*/
- public Measure setVariation4(Double d) {
+ public Measure setVariation4(@Nullable Double d) {
this.variation4 = d;
return this;
}
@@ -545,7 +549,7 @@ public class Measure<G extends Serializable> implements Serializable {
*
* @since 2.5
*/
- public Measure setVariation5(Double d) {
+ public Measure setVariation5(@Nullable Double d) {
this.variation5 = d;
return this;
}
@@ -665,7 +669,7 @@ public class Measure<G extends Serializable> implements Serializable {
* @since 2.14
*/
@Beta
- public Measure setPersonId(Integer i) {
+ public Measure setPersonId(@Nullable Integer i) {
this.personId = i;
return this;
}
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 dcb8120d196..a7bd3164bea 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
@@ -74,14 +74,14 @@ public class Metric<G extends Serializable> implements ServerExtension, BatchExt
RATING(String.class),
WORK_DUR(Long.class);
- private final Class valueType;
+ private final Class valueClass;
- private ValueType(Class measureJavaType) {
- this.valueType = measureJavaType;
+ private ValueType(Class valueClass) {
+ this.valueClass = valueClass;
}
private Class valueType() {
- return valueType;
+ return valueClass;
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
index 48852e7c4f2..c6f68aaedce 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
@@ -19,9 +19,10 @@
*/
package org.sonar.api.measures;
+import org.sonar.api.ServerComponent;
import org.sonar.api.task.TaskComponent;
-import org.sonar.api.ServerComponent;
+import javax.annotation.CheckForNull;
import java.util.Collection;
import java.util.List;
@@ -31,8 +32,10 @@ import java.util.List;
*/
public interface MetricFinder extends TaskComponent, ServerComponent {
+ @CheckForNull
Metric findById(int id);
+ @CheckForNull
Metric findByKey(String key);
Collection<Metric> findAll(List<String> metricKeys);