diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-03-15 16:41:22 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-03-16 14:04:34 +0100 |
commit | 712c66d95af8076fe3b4efd7392a61672dc7b656 (patch) | |
tree | 58cc574019f3416e66303affb946389d30629237 /sonar-batch/src | |
parent | 56eec4bfb1ad5b99e6bcf6b93806dbaa87cd6a13 (diff) | |
download | sonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.tar.gz sonarqube-712c66d95af8076fe3b4efd7392a61672dc7b656.zip |
SONAR-7414 Change Sensor API to update Issue#effortToFix to Issue#gap
Diffstat (limited to 'sonar-batch/src')
15 files changed, 48 insertions, 51 deletions
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")); |