From f51e80efde03d0af839d4991a31300f0f36088d3 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Thu, 15 Sep 2022 13:49:31 -0500 Subject: SONAR-17287 Fix quality issues and adopt changes to API --- .../sensor/issue/internal/AbstractDefaultIssue.java | 16 ++++++---------- .../batch/sensor/issue/internal/DefaultIssueFlow.java | 15 +++++++-------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'sonar-plugin-api-impl/src/main') diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java index 2fa3235e7c5..cc77d90a02f 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/AbstractDefaultIssue.java @@ -34,7 +34,7 @@ import org.sonar.api.batch.sensor.internal.DefaultStorable; import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.batch.sensor.issue.Issue.Flow; import org.sonar.api.batch.sensor.issue.IssueLocation; -import org.sonar.api.batch.sensor.issue.NewIssue; +import org.sonar.api.batch.sensor.issue.NewIssue.FlowType; import org.sonar.api.batch.sensor.issue.NewIssueLocation; import org.sonar.api.utils.PathUtils; @@ -72,25 +72,21 @@ public abstract class AbstractDefaultIssue exten } public T addLocation(NewIssueLocation secondaryLocation) { - flows.add(new DefaultIssueFlow(List.of(rewriteLocation((DefaultIssueLocation) secondaryLocation)), DefaultIssueFlow.Type.UNDEFINED, null)); + flows.add(new DefaultIssueFlow(List.of(rewriteLocation((DefaultIssueLocation) secondaryLocation)), FlowType.UNDEFINED, null)); return (T) this; } public T addFlow(Iterable locations) { - return addFlow(locations, DefaultIssueFlow.Type.UNDEFINED, null); + return addFlow(locations, FlowType.UNDEFINED, null); } - public T addFlow(Iterable flowLocations, NewIssue.FlowType flowType, @Nullable String flowDescription) { - return addFlow(flowLocations, DefaultIssueFlow.Type.valueOf(flowType.name()), flowDescription); - } - - private T addFlow(Iterable locations, DefaultIssueFlow.Type type, @Nullable String description) { + public T addFlow(Iterable flowLocations, FlowType type, @Nullable String flowDescription) { checkArgument(type != null, "Type can't be null"); List flowAsList = new ArrayList<>(); - for (NewIssueLocation issueLocation : locations) { + for (NewIssueLocation issueLocation : flowLocations) { flowAsList.add(rewriteLocation((DefaultIssueLocation) issueLocation)); } - flows.add(new DefaultIssueFlow(flowAsList, type, description)); + flows.add(new DefaultIssueFlow(flowAsList, type, flowDescription)); return (T) this; } diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueFlow.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueFlow.java index e4aabcc85da..76a47751c51 100644 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueFlow.java +++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssueFlow.java @@ -24,14 +24,15 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.batch.sensor.issue.Issue; import org.sonar.api.batch.sensor.issue.IssueLocation; +import org.sonar.api.batch.sensor.issue.NewIssue.FlowType; public class DefaultIssueFlow implements Issue.Flow { private final List locations; - private final Type type; + private final FlowType type; @Nullable private final String description; - public DefaultIssueFlow(List locations, Type type, @Nullable String description) { + public DefaultIssueFlow(List locations, FlowType type, @Nullable String description) { this.locations = locations; this.type = type; this.description = description; @@ -42,16 +43,14 @@ public class DefaultIssueFlow implements Issue.Flow { return locations; } - public Type getType() { + @Override + public FlowType type() { return type; } @CheckForNull - public String getDescription() { + @Override + public String description() { return description; } - - public enum Type { - UNDEFINED, DATA, EXECUTION; - } } -- cgit v1.2.3