本文整理汇总了Java中org.sonar.api.batch.sensor.issue.NewIssue.forRule方法的典型用法代码示例。如果您正苦于以下问题:Java NewIssue.forRule方法的具体用法?Java NewIssue.forRule怎么用?Java NewIssue.forRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.sensor.issue.NewIssue
的用法示例。
在下文中一共展示了NewIssue.forRule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIssuesForMutants
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void createIssuesForMutants(List<MutantResult> mutantResults, SensorContext context, MutantStatus targetStatus, String ruleKey) throws IOException {
if (isRuleActive(ruleKey)) {
int count = 0;
for (MutantResult mutantResult : mutantResults) {
if (mutantResult.getStatus() == targetStatus) {
count++;
InputFile file = locateSourceFile(mutantResult.getSourceFilePath());
NewIssue issue = context.newIssue();
NewIssueLocation location = issue.newLocation()
.on(file)
.at(mutantResult.getLocation().getRange(file))
.message(formatIssueMessage(mutantResult));
issue.at(location);
issue.forRule(RuleKey.of(RULE_REPOSITORY_KEY, ruleKey));
issue.save();
}
}
log.info("Reported {} issue(s) as {}.", count, targetStatus);
} else {
log.info("Skip reporting {} mutant(s), because rule {} is inactive", targetStatus, ruleKey);
}
}
示例2: createNewIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void createNewIssue(IssueAttributes issueAttributes, LocationAttributes locationAttributes, InputFile inputFile) {
Preconditions.checkNotNull(issueAttributes);
Preconditions.checkNotNull(locationAttributes);
Preconditions.checkNotNull(inputFile);
final NewIssue issue = sensorContext.newIssue();
final NewIssueLocation issueLocation = issue.newLocation();
issueLocation.on(inputFile);
issueLocation.at(inputFile.selectLine(locationAttributes.getLine().get()));
issueLocation.message(locationAttributes.getMessage().get());
issue.forRule(RuleKey.of(ColdFusionPlugin.REPOSITORY_KEY, issueAttributes.getId().get()));
issue.at(issueLocation);
issue.save();
}
示例3: createNewIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private boolean createNewIssue(final InputFile inputFile, final XMLReportFinding xanFinding,
final SensorContext sensorContext) {
final GeneratedProblemType pt = xanFinding.getProblemType();
final RuleKey ruleKey = RuleKey.of(XanitizerRulesDefinition.REPOSITORY_KEY, pt.name());
final int lineNo = normalizeLineNo(xanFinding.getLocation().getLineNoOrMinus1());
final Severity severity = SensorUtil.mkSeverity(xanFinding);
final String issueKey = mkIssueKey(ruleKey, inputFile, lineNo);
final NewIssue alreadyCreatedIssue = alreadyCreatedIssues.get(issueKey);
if (alreadyCreatedIssue != null) {
addSecondaryLocation(alreadyCreatedIssue, xanFinding, sensorContext);
LOG.debug("Issue already exists: " + inputFile + ":" + lineNo + " - "
+ pt.getPresentationName());
return false;
}
final NewIssue newIssue = sensorContext.newIssue();
newIssue.forRule(ruleKey);
newIssue.overrideSeverity(severity);
final NewIssueLocation newIssueLocation = newIssue.newLocation();
newIssueLocation.on(inputFile);
// If line number exceeds the current length of the file,
// SonarQube will crash. So check length for robustness.
if (lineNo <= inputFile.lines()) {
final TextRange textRange = inputFile.selectLine(lineNo);
newIssueLocation.at(textRange);
}
newIssueLocation.message(pt.getMessage());
newIssue.at(newIssueLocation);
addSecondaryLocation(newIssue, xanFinding, sensorContext);
alreadyCreatedIssues.put(issueKey, newIssue);
LOG.debug("Issue saved: " + inputFile + ":" + lineNo + " - " + pt.getPresentationName());
return true;
}