当前位置: 首页>>代码示例>>Java>>正文


Java NewIssue.forRule方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:stryker-mutator,项目名称:sonar-stryker-plugin,代码行数:24,代码来源:StrykerSensor.java

示例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();
}
 
开发者ID:stepstone-tech,项目名称:sonar-coldfusion,代码行数:17,代码来源:CFlintAnalysisResultImporter.java

示例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;
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:43,代码来源:XanitizerSensor.java


注:本文中的org.sonar.api.batch.sensor.issue.NewIssue.forRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。