aboutsummaryrefslogtreecommitdiffstats
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
parent56eec4bfb1ad5b99e6bcf6b93806dbaa87cd6a13 (diff)
downloadsonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.tar.gz
sonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.zip
SONAR-7414 Change Sensor API to update Issue#effortToFix to Issue#gap
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java3
-rw-r--r--sonar-batch-protocol/src/main/protobuf/batch_report.proto2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/DefaultFilterableIssue.java14
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilter.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssueTransformer.java19
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/TrackedIssue.java10
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/DefaultFilterableIssueTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilterTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/TrackedIssueAdapterTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java28
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java2
-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
23 files changed, 96 insertions, 63 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
index b557b1a0133..4af4e673a9c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
@@ -125,8 +125,8 @@ public class TrackerRawInputFactory {
if (reportIssue.hasSeverity()) {
issue.setSeverity(reportIssue.getSeverity().name());
}
- if (reportIssue.hasEffortToFix()) {
- issue.setGap(reportIssue.getEffortToFix());
+ if (reportIssue.hasGap()) {
+ issue.setGap(reportIssue.getGap());
}
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder();
if (reportIssue.hasTextRange()) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java
index 90c6399d0ab..c2d2baab706 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java
@@ -93,7 +93,7 @@ public class TrackerRawInputFactoryTest {
.setRuleRepository("java")
.setRuleKey("S001")
.setSeverity(Constants.Severity.BLOCKER)
- .setEffortToFix(3.14)
+ .setGap(3.14)
.build();
reportReader.putIssues(FILE.getReportAttributes().getRef(), asList(reportIssue));
Input<DefaultIssue> input = underTest.create(FILE);
@@ -107,6 +107,7 @@ public class TrackerRawInputFactoryTest {
assertThat(issue.severity()).isEqualTo(Severity.BLOCKER);
assertThat(issue.line()).isEqualTo(2);
assertThat(issue.effortToFix()).isEqualTo(3.14);
+ assertThat(issue.gap()).isEqualTo(3.14);
assertThat(issue.message()).isEqualTo("the message");
// fields set by compute engine
diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
index 2913e856fb2..2abebf20e00 100644
--- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto
+++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto
@@ -100,7 +100,7 @@ message Issue {
optional int32 line = 3;
optional string msg = 4;
optional Severity severity = 5;
- optional double effort_to_fix = 6;
+ optional double gap = 6;
// Only when issue component is a file. Can also be empty for a file if this is an issue global to the file.
optional TextRange text_range = 7;
repeated Flow flow = 8;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultFilterableIssue.java b/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultFilterableIssue.java
index a66d2cefa50..a7f28e5bfa4 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultFilterableIssue.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/DefaultFilterableIssue.java
@@ -19,16 +19,13 @@
*/
package org.sonar.batch.issue;
+import java.util.Date;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
-
import org.sonar.api.resources.Project;
import org.sonar.api.rule.RuleKey;
-
-import java.util.Date;
-
-import org.sonar.batch.protocol.output.BatchReport.Issue;
import org.sonar.api.scan.issue.filter.FilterableIssue;
+import org.sonar.batch.protocol.output.BatchReport.Issue;
public class DefaultFilterableIssue implements FilterableIssue {
private final Issue rawIssue;
@@ -68,8 +65,13 @@ public class DefaultFilterableIssue implements FilterableIssue {
}
@Override
+ public Double gap() {
+ return rawIssue.hasGap() ? rawIssue.getGap() : null;
+ }
+
+ @Override
public Double effortToFix() {
- return rawIssue.hasEffortToFix() ? rawIssue.getEffortToFix() : null;
+ return gap();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilter.java b/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilter.java
index 567f66a3fcf..f6df0fdbd39 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilter.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilter.java
@@ -88,7 +88,7 @@ class DeprecatedIssueAdapterForFilter implements Issue {
@Override
public Double gap() {
- return rawIssue.hasEffortToFix() ? rawIssue.getEffortToFix() : null;
+ return rawIssue.hasGap() ? rawIssue.getGap() : null;
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueTransformer.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueTransformer.java
index 53905a2e5cf..b606854be93 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueTransformer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueTransformer.java
@@ -19,26 +19,23 @@
*/
package org.sonar.batch.issue;
-import org.sonar.batch.issue.tracking.SourceHashHolder;
-
-import org.sonar.batch.protocol.input.BatchInput.ServerIssue;
import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import javax.annotation.Nullable;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.issue.tracking.SourceHashHolder;
import org.sonar.batch.issue.tracking.TrackedIssue;
+import org.sonar.batch.protocol.input.BatchInput.ServerIssue;
import org.sonar.batch.protocol.output.BatchReport;
import org.sonar.batch.protocol.output.BatchReport.TextRange;
import org.sonar.core.component.ComponentKeys;
import org.sonar.core.util.Uuids;
-import javax.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
public class IssueTransformer {
private IssueTransformer() {
// static only
@@ -96,7 +93,7 @@ public class IssueTransformer {
issue.setKey(Uuids.createFast());
issue.setComponentKey(component.key());
issue.setRuleKey(ruleKey);
- issue.setEffortToFix(rawIssue.hasEffortToFix() ? rawIssue.getEffortToFix() : null);
+ issue.setGap(rawIssue.hasGap() ? rawIssue.getGap() : null);
issue.setSeverity(rawIssue.getSeverity().name());
issue.setMessage(rawIssue.hasMsg() ? rawIssue.getMsg() : null);
issue.setResolution(null);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
index eff02beb953..fb798fd563b 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
@@ -91,9 +91,9 @@ public class ModuleIssues {
builder.setLine(primaryTextRange.start().line());
builder.setTextRange(toProtobufTextRange(primaryTextRange));
}
- Double effortToFix = issue.effortToFix();
- if (effortToFix != null) {
- builder.setEffortToFix(effortToFix);
+ Double gap = issue.gap();
+ if (gap != null) {
+ builder.setGap(gap);
}
applyFlows(issue);
BatchReport.Issue rawIssue = builder.build();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
index f8f21ea2e0e..19027847d9d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/TrackedIssueAdapter.java
@@ -79,7 +79,7 @@ public class TrackedIssueAdapter implements Issue {
@Override
public Double gap() {
- return issue.effortToFix();
+ return issue.gap();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/TrackedIssue.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/TrackedIssue.java
index 16f4273b67e..ea303bf6a4f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/TrackedIssue.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/TrackedIssue.java
@@ -39,7 +39,7 @@ public class TrackedIssue implements Trackable, Serializable {
private Integer startLineOffset;
private Integer endLine;
private Integer endLineOffset;
- private Double effortToFix;
+ private Double gap;
private boolean isNew;
private Date creationDate;
private String resolution;
@@ -186,8 +186,8 @@ public class TrackedIssue implements Trackable, Serializable {
return severity;
}
- public Double effortToFix() {
- return effortToFix;
+ public Double gap() {
+ return gap;
}
public Date getCreationDate() {
@@ -222,8 +222,8 @@ public class TrackedIssue implements Trackable, Serializable {
return this;
}
- public TrackedIssue setEffortToFix(Double effortToFix) {
- this.effortToFix = effortToFix;
+ public TrackedIssue setGap(Double gap) {
+ this.gap = gap;
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java b/sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
index 75a80981793..02b1582b999 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
@@ -108,7 +108,7 @@ public class DefaultPostJobContext implements PostJobContext {
@Override
public Double effortToFix() {
- return wrapped.effortToFix();
+ return wrapped.gap();
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
index 3ad574574d9..f0c2e2b6da7 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
@@ -148,7 +148,7 @@ public class JSONReport implements Reporter {
.prop("resolution", issue.resolution())
.prop("isNew", issue.isNew())
.prop("assignee", issue.assignee())
- .prop("effortToFix", issue.effortToFix())
+ .prop("effortToFix", issue.gap())
.propDateTime("creationDate", issue.creationDate());
if (!StringUtils.isEmpty(issue.reporter())) {
logins.add(issue.reporter());
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/DefaultFilterableIssueTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/DefaultFilterableIssueTest.java
index 8c0c70d822e..4e1ed3d053a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/DefaultFilterableIssueTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/DefaultFilterableIssueTest.java
@@ -47,7 +47,7 @@ public class DefaultFilterableIssueTest {
private Issue createIssue() {
Issue.Builder builder = Issue.newBuilder();
- builder.setEffortToFix(3.0);
+ builder.setGap(3.0);
builder.setLine(30);
builder.setSeverity(Severity.MAJOR);
return builder.build();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilterTest.java
index 952b0c587fd..ba835314e53 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedIssueAdapterForFilterTest.java
@@ -52,7 +52,7 @@ public class DeprecatedIssueAdapterForFilterTest {
.setSeverity(Severity.BLOCKER)
.setMsg("msg")
.setLine(1)
- .setEffortToFix(2.0)
+ .setGap(2.0)
.build(),
COMPONENT_KEY);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/TrackedIssueAdapterTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/TrackedIssueAdapterTest.java
index 268ee46371f..11fc560b318 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/TrackedIssueAdapterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/TrackedIssueAdapterTest.java
@@ -39,7 +39,7 @@ public class TrackedIssueAdapterTest {
.setSeverity("MAJOR")
.setMessage("msg")
.setStartLine(1)
- .setEffortToFix(2.0)
+ .setGap(2.0)
.setStatus("RESOLVED")
.setResolution("FIXED")
.setReporter("toto")
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java
index 70d31c2f8a2..418b1104404 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/ProjectBuilderMediumTest.java
@@ -19,9 +19,11 @@
*/
package org.sonar.batch.mediumtest.fs;
-import org.sonar.api.utils.MessageException;
-
import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
@@ -29,24 +31,20 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.utils.MessageException;
import org.sonar.batch.mediumtest.BatchMediumTester;
import org.sonar.batch.mediumtest.TaskResult;
import org.sonar.batch.protocol.output.BatchReport.Issue;
import org.sonar.xoo.XooPlugin;
import org.sonar.xoo.rule.XooRulesDefinition;
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-
import static org.assertj.core.api.Assertions.assertThat;
public class ProjectBuilderMediumTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
-
+
@Rule
public ExpectedException exception = ExpectedException.none();
@@ -71,7 +69,7 @@ public class ProjectBuilderMediumTest {
@Test
public void testProjectBuilder() throws IOException {
File baseDir = prepareProject();
-
+
TaskResult result = tester.newTask()
.properties(ImmutableMap.<String, String>builder()
.put("sonar.task", "scan")
@@ -92,18 +90,18 @@ public class ProjectBuilderMediumTest {
if (issue.getLine() == 1) {
foundIssueAtLine1 = true;
assertThat(issue.getMsg()).isEqualTo("This issue is generated on each line");
- assertThat(issue.hasEffortToFix()).isFalse();
+ assertThat(issue.hasGap()).isFalse();
}
}
assertThat(foundIssueAtLine1).isTrue();
}
-
+
@Test
// SONAR-6976
public void testProjectBuilderWithNewLine() throws IOException {
File baseDir = prepareProject();
-
+
exception.expect(MessageException.class);
exception.expectMessage("is not a valid branch name");
tester.newTask()
@@ -147,12 +145,12 @@ public class ProjectBuilderMediumTest {
if (issue.getLine() == 1) {
foundIssueAtLine1 = true;
assertThat(issue.getMsg()).isEqualTo("This issue is generated on each line");
- assertThat(issue.hasEffortToFix()).isFalse();
+ assertThat(issue.hasGap()).isFalse();
}
}
assertThat(foundIssueAtLine1).isTrue();
}
-
+
private File prepareProject() throws IOException {
File baseDir = temp.getRoot();
File module1Dir = new File(baseDir, "module1");
@@ -163,7 +161,7 @@ public class ProjectBuilderMediumTest {
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10");
-
+
return baseDir;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java
index a6bb661943e..176c51ca5d7 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/IssuesMediumTest.java
@@ -106,7 +106,7 @@ public class IssuesMediumTest {
.start();
List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
- assertThat(issues).hasSize(8 /* lines */+ 1 /* file */);
+ assertThat(issues).hasSize(8 /* lines */ + 1 /* file */);
}
@Test
@@ -170,7 +170,7 @@ public class IssuesMediumTest {
if (issue.getLine() == 1) {
foundIssueAtLine1 = true;
assertThat(issue.getMsg()).isEqualTo("This issue is generated on each line");
- assertThat(issue.hasEffortToFix()).isFalse();
+ assertThat(issue.hasGap()).isFalse();
}
}
assertThat(foundIssueAtLine1).isTrue();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java b/sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
index 9c1abdc2d8c..12f00a55d90 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
@@ -61,7 +61,7 @@ public class DefaultPostJobContextTest {
TrackedIssue defaultIssue = new TrackedIssue();
defaultIssue.setComponentKey("foo:src/Foo.php");
- defaultIssue.setEffortToFix(2.0);
+ defaultIssue.setGap(2.0);
defaultIssue.setNew(true);
defaultIssue.setKey("xyz");
defaultIssue.setStartLine(1);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
index 653b26e09bb..fdeadc562dd 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
@@ -111,7 +111,7 @@ public class JSONReportTest {
issue.setEndLine(2);
issue.setStartLineOffset(3);
issue.setEndLineOffset(4);
- issue.setEffortToFix(3.14);
+ issue.setGap(3.14);
issue.setReporter("julien");
issue.setAssignee("simon");
issue.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"));
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();