public void execute(SensorContext sensorContext, InputFile file, RuleKey ruleKey) {
sensorContext.newIssue()
.onFile(file)
- .ruleKey(ruleKey)
+ .forRule(ruleKey)
.atLine(line)
.save();
}
context.settings().getString(INTERNAL_KEY_PROPERTY));
if (rule != null) {
context.newIssue()
- .ruleKey(rule.ruleKey())
+ .forRule(rule.ruleKey())
.onFile(file)
.message("This issue is generated on each file")
.save();
InputDir inputDir = context.fileSystem().inputDir(file.file().getParentFile());
if (inputDir != null) {
context.newIssue()
- .ruleKey(ruleKey)
+ .forRule(ruleKey)
.onDir(inputDir)
.message("This issue is generated for file " + file.relativePath())
.save();
String severity = context.settings().getString(FORCE_SEVERITY_PROPERTY);
for (int line = 1; line <= file.lines(); line++) {
context.newIssue()
- .ruleKey(ruleKey)
+ .forRule(ruleKey)
.onFile(file)
.atLine(line)
.effortToFix(context.settings().getDouble(EFFORT_TO_FIX_PROPERTY))
private void createIssues(InputFile file, SensorContext context) {
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
context.newIssue()
- .ruleKey(ruleKey)
+ .forRule(ruleKey)
.onFile(file)
.atLine(1)
.message("This issue is generated on each file")
sensorStorage.store(new DefaultIssue()
.onFile(file)
- .ruleKey(RuleKey.of("foo", "bar"))
+ .forRule(RuleKey.of("foo", "bar"))
.message("Foo")
.atLine(3)
.effortToFix(10.0));
sensorStorage.store(new DefaultIssue()
.onDir(dir)
- .ruleKey(RuleKey.of("foo", "bar"))
+ .forRule(RuleKey.of("foo", "bar"))
.message("Foo")
.effortToFix(10.0));
sensorStorage.store(new DefaultIssue()
.onProject()
- .ruleKey(RuleKey.of("foo", "bar"))
+ .forRule(RuleKey.of("foo", "bar"))
.message("Foo")
.overrideSeverity(Severity.BLOCKER)
.effortToFix(10.0));
/**
* The {@link RuleKey} of the issue.
*/
- NewIssue ruleKey(RuleKey ruleKey);
+ NewIssue forRule(RuleKey ruleKey);
/**
* The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}.
}
@Override
- public DefaultIssue ruleKey(RuleKey ruleKey) {
+ public DefaultIssue forRule(RuleKey ruleKey) {
this.ruleKey = ruleKey;
return this;
}
package org.sonar.api.issue;
+import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.Perspective;
import org.sonar.api.rule.RuleKey;
import javax.annotation.Nullable;
+
import java.util.List;
/**
*/
public interface Issuable extends Perspective {
+ /**
+ * @deprecated since 5.1 use {@link SensorContext#newIssue()}
+ */
+ @Deprecated
interface IssueBuilder {
/**
* The rule key is mandatory. Example: {@code RuleKey.of("pmd", "AvoidArrayLoops")}
/**
* Builder is used to create the issue to be passed to {@link #addIssue(Issue)}
+ * @deprecated since 5.1 use {@link SensorContext#newIssue()}
*/
+ @Deprecated
IssueBuilder newIssueBuilder();
/**
* method must be annotated with {@code @DependedUpon(DecoratorBarriers.ISSUES_ADDED)}.
*
* @return true if the new issue is registered, false if the related rule does not exist or is disabled in the Quality profile.
+ * @deprecated since 5.1 use {@link SensorContext#newIssue()}
*/
+ @Deprecated
boolean addIssue(Issue issue);
/**
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(storage)
.onFile(new DefaultInputFile("foo", "src/Foo.php"))
- .ruleKey(RuleKey.of("repo", "rule"))
+ .forRule(RuleKey.of("repo", "rule"))
.atLine(1)
.effortToFix(10.0)
.message("Wrong way!");
SensorStorage storage = mock(SensorStorage.class);
DefaultIssue issue = new DefaultIssue(storage)
.onProject()
- .ruleKey(RuleKey.of("repo", "rule"))
+ .forRule(RuleKey.of("repo", "rule"))
.effortToFix(10.0)
.message("Wrong way!");
new DefaultIssue()
.onProject()
.onFile(new DefaultInputFile("foo", "src/Foo.php"))
- .ruleKey(RuleKey.of("repo", "rule"))
+ .forRule(RuleKey.of("repo", "rule"))
.atLine(1)
.effortToFix(10.0)
.message("Wrong way!");