本文整理汇总了Java中org.sonar.api.batch.sensor.issue.NewIssueLocation.message方法的典型用法代码示例。如果您正苦于以下问题:Java NewIssueLocation.message方法的具体用法?Java NewIssueLocation.message怎么用?Java NewIssueLocation.message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.sensor.issue.NewIssueLocation
的用法示例。
在下文中一共展示了NewIssueLocation.message方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的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();
}
示例2: addSecondaryLocation
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
private void addSecondaryLocation(final NewIssue issue, final XMLReportFinding xanFinding,
final SensorContext sensorContext) {
final InputFile secondaryFile = mkInputFileOrNull(xanFinding.getSecondaryLocationOrNull(),
sensorContext);
if (secondaryFile != null) {
final NewIssueLocation secondaryLocation = issue.newLocation();
secondaryLocation.on(secondaryFile);
secondaryLocation.message(xanFinding.getSecondaryLocationMessage());
final int secondaryLine = normalizeLineNo(
xanFinding.getSecondaryLocationOrNull().getLineNoOrMinus1());
if (secondaryLine <= secondaryFile.lines()) {
final TextRange textRange = secondaryFile.selectLine(secondaryLine);
secondaryLocation.at(textRange);
}
issue.addLocation(secondaryLocation);
LOG.debug("Added secondary location for finding " + xanFinding.getFindingID());
}
}
示例3: fill
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
@Override
public void fill(final SensorContext context, final InputFile inputFile,
final TsqlIssue... issues) {
for (final TsqlIssue error : issues) {
InputFile file = inputFile;
try {
if (error.getLine() < 1) {
LOGGER.warn(
format("Can't add issue %s on file %s as line is 0", error.getType(), error.getFilePath()));
continue;
}
if (file == null){
final FileSystem fileSystem = context.fileSystem();
file = fileSystem.inputFile(fileSystem.predicates().and(error.getPredicate()));
if (file == null) {
LOGGER.debug(format("Cound not find file %s to add issue %s at line %d.", error.getFilePath(),
error.getType(), error.getLine()));
continue;
}
}
final RuleKey rule = RuleKey.of(error.getRepositoryKey(), error.getType());
final NewIssue issue = context.newIssue().forRule(rule);
final NewIssueLocation loc = issue.newLocation().on(file).at(file.selectLine(error.getLine()));
if (error.getDescription() != null) {
loc.message(error.getDescription());
}
issue.at(loc).save();
} catch (final Throwable e) {
LOGGER.warn(format("Can't add issue %s on file %s at line %d.", error.getType(), file.absolutePath(),
error.getLine()), e);
}
}
}
示例4: onIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
@Override
public void onIssue(String ruleId, Location primaryLocation, Collection<Location> secondaryLocations) {
String repositoryKey = repositoryKeyByRoslynRuleKey.get(ruleId);
if (repositoryKey == null) {
return;
}
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates()
.hasAbsolutePath(primaryLocation.getAbsolutePath()));
if (inputFile == null) {
return;
}
NewIssue newIssue = context.newIssue();
newIssue
.forRule(RuleKey.of(repositoryKey, ruleId))
.at(newIssue.newLocation()
.on(inputFile)
.at(inputFile.newRange(primaryLocation.getStartLine(), primaryLocation.getStartColumn(),
primaryLocation.getEndLine(), primaryLocation.getEndColumn()))
.message(primaryLocation.getMessage()));
for (Location secondaryLocation : secondaryLocations) {
if (!inputFile.absolutePath().equalsIgnoreCase(secondaryLocation.getAbsolutePath())) {
inputFile = context.fileSystem().inputFile(context.fileSystem().predicates()
.hasAbsolutePath(secondaryLocation.getAbsolutePath()));
if (inputFile == null) {
return;
}
}
NewIssueLocation newIssueLocation = newIssue.newLocation()
.on(inputFile)
.at(inputFile.newRange(secondaryLocation.getStartLine(), secondaryLocation.getStartColumn(),
secondaryLocation.getEndLine(), secondaryLocation.getEndColumn()));
String secondaryLocationMessage = secondaryLocation.getMessage();
if (secondaryLocationMessage != null) {
newIssueLocation.message(secondaryLocationMessage);
}
newIssue.addLocation(newIssueLocation);
}
newIssue.save();
}
示例5: createNewIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的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;
}