aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-03-15 16:41:22 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2016-03-16 14:04:34 +0100
commit712c66d95af8076fe3b4efd7392a61672dc7b656 (patch)
tree58cc574019f3416e66303affb946389d30629237 /sonar-plugin-api
parent56eec4bfb1ad5b99e6bcf6b93806dbaa87cd6a13 (diff)
downloadsonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.tar.gz
sonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.zip
SONAR-7414 Change Sensor API to update Issue#effortToFix to Issue#gap
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java18
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java12
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java4
5 files changed, 43 insertions, 8 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java
index 0f3f88cb1a0..1f275390788 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/Issue.java
@@ -48,11 +48,20 @@ public interface Issue {
/**
* Effort to fix the issue. Used by technical debt model.
+ * @deprecated since 5.5 use {@link #gap()}
*/
@CheckForNull
+ @Deprecated
Double effortToFix();
/**
+ * Gap used to compute the effort for fixing the issue.
+ * @since 5.5
+ */
+ @CheckForNull
+ Double gap();
+
+ /**
* Overridden severity.
*/
@CheckForNull
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java
index a4a22f50b0e..2dbf02b31d1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/NewIssue.java
@@ -40,10 +40,18 @@ public interface NewIssue {
/**
* Effort to fix the issue.
+ * @deprecated since 5.5 use {@link #gap(Double)}
*/
+ @Deprecated
NewIssue effortToFix(@Nullable Double effortToFix);
/**
+ * Gap used for the computation of the effort.
+ * @since 5.5
+ */
+ NewIssue gap(@Nullable Double gap);
+
+ /**
* Override severity of the issue.
* Setting a null value or not calling this method means to use severity configured in quality profile.
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
index c2bf9bf12ef..2ee5cc74ab4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
@@ -53,7 +53,7 @@ public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
}
private RuleKey ruleKey;
- private Double effortToFix;
+ private Double gap;
private Severity overriddenSeverity;
private IssueLocation primaryLocation;
private List<List<IssueLocation>> flows = new ArrayList<>();
@@ -74,8 +74,13 @@ public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
@Override
public DefaultIssue effortToFix(@Nullable Double effortToFix) {
- Preconditions.checkArgument(effortToFix == null || effortToFix >= 0, format("Effort to fix must be greater than or equal 0 (got %s)", effortToFix));
- this.effortToFix = effortToFix;
+ return gap(effortToFix);
+ }
+
+ @Override
+ public DefaultIssue gap(@Nullable Double gap) {
+ Preconditions.checkArgument(gap == null || gap >= 0, format("Gap must be greater than or equal 0 (got %s)", gap));
+ this.gap = gap;
return this;
}
@@ -125,8 +130,13 @@ public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
}
@Override
+ public Double gap() {
+ return this.gap;
+ }
+
+ @Override
public Double effortToFix() {
- return this.effortToFix;
+ return this.gap;
}
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
index dc66b00b1bb..026ccf439cb 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/issue/filter/FilterableIssue.java
@@ -19,9 +19,8 @@
*/
package org.sonar.api.scan.issue.filter;
-import org.sonar.api.rule.RuleKey;
-
import java.util.Date;
+import org.sonar.api.rule.RuleKey;
/**
* @since 5.3
@@ -38,8 +37,17 @@ public interface FilterableIssue {
Integer line();
+ /**
+ * @deprecated since 5.5 use {@link #gap()}
+ */
+ @Deprecated
Double effortToFix();
+ /**
+ * @since 5.5
+ */
+ Double gap();
+
Date creationDate();
String projectKey();
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java
index ca629c6baf2..6b380a0c6b7 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueTest.java
@@ -46,12 +46,12 @@ public class DefaultIssueTest {
.at(inputFile.selectLine(1))
.message("Wrong way!"))
.forRule(RuleKey.of("repo", "rule"))
- .effortToFix(10.0);
+ .gap(10.0);
assertThat(issue.primaryLocation().inputComponent()).isEqualTo(inputFile);
assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule"));
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
- assertThat(issue.effortToFix()).isEqualTo(10.0);
+ assertThat(issue.gap()).isEqualTo(10.0);
assertThat(issue.primaryLocation().message()).isEqualTo("Wrong way!");
issue.save();