Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 13.5
* Introduce support for issue resolution from sensors:
* Introduce `org.sonar.api.batch.sensor.issue.NewIssueResolution`
* Introduce `org.sonar.api.batch.sensor.issue.IssueResolution`
* Introduce `org.sonar.api.batch.sensor.SensorContext.newIssueResolution()`
* Introduce `org.sonar.api.batch.sensor.internal.SensorStorage.store(IssueResolution)`

## 13.4
* Add `org.sonar.api.a3s.A3SContextCollector` (internal SonarSource usage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
import org.sonar.api.batch.sensor.issue.ExternalIssue;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.IssueResolution;
import org.sonar.api.batch.sensor.issue.NewExternalIssue;
import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.batch.sensor.issue.NewIssueResolution;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.rule.AdHocRule;
Expand Down Expand Up @@ -305,4 +307,11 @@ public interface SensorContext {
*/
@Beta
boolean isFeatureAvailable(String featureName);

/**
* Builder to create a new {@link IssueResolution}.
* Don't forget to call {@link NewIssueResolution#save()} once all parameters are provided.
* @since 13.5
*/
NewIssueResolution newIssueResolution();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
import org.sonar.api.batch.sensor.issue.ExternalIssue;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.IssueResolution;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.rule.AdHocRule;
import org.sonar.api.batch.sensor.symbol.NewSymbolTable;
Expand Down Expand Up @@ -82,4 +83,9 @@ public interface SensorStorage {
* @since 7.2
*/
void store(NewSignificantCode significantCode);

/**
* @since 13.5
*/
void store(IssueResolution issueResolution);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Sonar Plugin API
* Copyright (C) 2009-2025 SonarSource Sàrl
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.api.batch.sensor.issue;

import java.util.Set;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.rule.RuleKey;

/**
* Represents a request to resolve one or more issues at a given location.
*
* @since 13.5
*/
public interface IssueResolution {

enum Status {DEFAULT, FALSE_POSITIVE}

InputFile inputFile();

TextRange textRange();

Status status();

Set<RuleKey> ruleKeys();

String comment();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Sonar Plugin API
* Copyright (C) 2009-2025 SonarSource Sàrl
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.api.batch.sensor.issue;

import java.util.Collection;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.rule.RuleKey;

/**
* Builder for an {@link IssueResolution}. Use {@code context.newIssueResolution()} to create.
* {@link #save()} should be called once all parameters are provided.
*
* @since 13.5
*/
public interface NewIssueResolution {

/**
* Set the target file.
*/
NewIssueResolution on(InputFile inputFile);

/**
* Set the target text range within the file.
*/
NewIssueResolution at(TextRange textRange);

/**
* Set the resolution status. Defaults to {@link IssueResolution.Status#DEFAULT}.
*/
NewIssueResolution status(IssueResolution.Status status);

/**
* Set the target rule keys. At least one rule key is required.
*/
NewIssueResolution forRules(Collection<RuleKey> ruleKeys);

/**
* Set a justification comment. Required.
*/
NewIssueResolution comment(String comment);

/**
* Save the issue resolution.
*/
void save();
}
Loading