import com.google.common.annotations.Beta;
import java.util.List;
-import java.util.Map;
import javax.annotation.CheckForNull;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.Sensor;
*/
List<Flow> flows();
- /**
- * Key/value pair of attributes that are attached to the issue.
- * @since 5.2
- */
- Map<String, String> attributes();
-
}
*/
NewIssueLocation newLocation();
- /**
- * Attach a new attribute to the issue. Not used by SQ but can be reused later for integration needs (for example it is returned by WS).
- * @since 5.2
- */
- NewIssue addAttribute(String key, String value);
-
/**
* Save the issue. If rule key is unknown or rule not enabled in the current quality profile then a warning is logged but no exception
* is thrown.
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import javax.annotation.Nullable;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
private Severity overriddenSeverity;
private IssueLocation primaryLocation;
private List<List<IssueLocation>> flows = new ArrayList<>();
- private final Map<String, String> attributes = new LinkedHashMap<>();
public DefaultIssue() {
super(null);
return this;
}
- @Override
- public DefaultIssue addAttribute(String key, String value) {
- attributes.put(key, value);
- return this;
- }
-
- @Override
- public Map<String, String> attributes() {
- return ImmutableMap.copyOf(attributes);
- }
-
@Override
public RuleKey ruleKey() {
return this.ruleKey;