本文整理汇总了Java中org.sonar.api.batch.sensor.issue.NewIssueLocation.at方法的典型用法代码示例。如果您正苦于以下问题:Java NewIssueLocation.at方法的具体用法?Java NewIssueLocation.at怎么用?Java NewIssueLocation.at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.sensor.issue.NewIssueLocation
的用法示例。
在下文中一共展示了NewIssueLocation.at方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
private void saveIssue(final SensorContext context, final InputFile inputFile, String lineString, final String externalRuleKey, final String message) {
RuleKey ruleKey = RuleKey.of(FramaCRulesDefinition.getRepositoryKeyForLanguage(), externalRuleKey);
LOGGER.info("externalRuleKey: "+externalRuleKey);
LOGGER.info("Repo: "+FramaCRulesDefinition.getRepositoryKeyForLanguage());
LOGGER.info("RuleKey: "+ruleKey);
NewIssue newIssue = context.newIssue()
.forRule(ruleKey);
NewIssueLocation primaryLocation = newIssue.newLocation()
.on(inputFile)
.message(message);
int maxLine = inputFile.lines();
int iLine = getLineAsInt(lineString, maxLine);
if (iLine > 0) {
primaryLocation.at(inputFile.selectLine(iLine));
}
newIssue.at(primaryLocation);
newIssue.save();
}
示例2: consumeFor
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
@Override
void consumeFor(InputFile inputFile, FileIssues message) {
for (SonarAnalyzer.FileIssues.Issue issue : message.getIssueList()) {
NewIssue newIssue = context.newIssue();
NewIssueLocation location = newIssue
.newLocation()
.on(inputFile)
.message(issue.getMessage());
SonarAnalyzer.TextRange issueTextRange = issue.getLocation();
if (issueTextRange.getStartOffset() == issueTextRange.getEndOffset() &&
issueTextRange.getStartLine() == issueTextRange.getEndLine()) {
// file level issue
} else {
location = location.at(toTextRange(inputFile, issueTextRange));
}
newIssue.forRule(RuleKey.of(repositoryKey, issue.getId()))
.at(location)
.save();
}
}
示例3: saveIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
void saveIssue(InputFile inputFile, int line, String externalRuleKey, String message) {
RuleKey rule = RuleKey.of(PerlCriticRulesDefinition.getRepositoryKey(), externalRuleKey);
if (activeRules.find(rule) == null) {
log.info("Ignoring unknown or deactivated issue of type {}", rule);
return;
}
log.debug("Saving an issue of type {} on file {}", rule, inputFile);
NewIssue issue = this.context.newIssue().forRule(rule);
NewIssueLocation location = issue.newLocation().message(message).on(inputFile);
if (line > 0) {
location.at(inputFile.selectLine(line));
}
issue.at(location);
issue.save();
}
示例4: 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();
}
示例5: 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());
}
}
示例6: saveIssues
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
private void saveIssues(InputFile inputFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
for (CheckMessage message : messages) {
RuleKey ruleKey = checks.ruleKey((SquidAstVisitor<Grammar>) message.getCheck());
NewIssue newIssue = context.newIssue();
NewIssueLocation primaryLocation = newIssue.newLocation()
.message(message.getText(Locale.ENGLISH))
.on(inputFile);
if (message.getLine() != null) {
primaryLocation.at(inputFile.selectLine(message.getLine()));
}
newIssue.forRule(ruleKey).at(primaryLocation).save();
}
}
示例7: saveViolations
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
private void saveViolations(SensorContext context, InputFile inputFile, SourceFile squidFile) {
Collection<CheckMessage> messages = squidFile.getCheckMessages();
if (messages != null) {
for (CheckMessage message : messages) {
RuleKey ruleKey = checks.ruleKey((SquidCheck<LexerlessGrammar>) message.getCheck());
NewIssue newIssue = context.newIssue()
.forRule(ruleKey)
.gap(message.getCost());
Integer line = message.getLine();
NewIssueLocation location = newIssue.newLocation()
.on(inputFile)
.message(message.getText(Locale.ENGLISH));
if (line != null) {
location.at(inputFile.selectLine(line));
}
newIssue.at(location);
newIssue.save();
}
}
}
示例8: createMissingIssues
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
@VisibleForTesting
private void createMissingIssues(SensorContext context, InputComponent resource) {
Multiset<IssueKey> componentIssues = checker.getByComponentKey(resource.key());
if (!componentIssues.isEmpty()) {
checker.disabled = true;
for (IssueKey issueKey : checker.getByComponentKey(resource.key())) {
// missing issue => create
checker.different = true;
RuleKey ruleKey = RuleKey.parse(issueKey.ruleKey);
ActiveRule activeRule = profile.getActiveRule(ruleKey.repository(), ruleKey.rule());
if (activeRule == null) {
// rule not active => skip it
checker.inactiveRule(issueKey.ruleKey);
continue;
}
checker.differences++;
NewIssue newIssue = context.newIssue();
NewIssueLocation location = newIssue.newLocation()
.on(resource)
.message("Missing");
if (issueKey.line != 0) {
location.at(((InputFile) resource).selectLine(issueKey.line));
}
newIssue
.forRule(ruleKey)
.overrideSeverity(Severity.BLOCKER)
.at(location)
.save();
}
checker.disabled = false;
componentIssues.clear();
}
}
示例9: saveIssue
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
@VisibleForTesting
protected void saveIssue(SensorContext context, XmlSourceCode sourceCode) {
for (XmlIssue xmlIssue : sourceCode.getXmlIssues()) {
NewIssue newIssue = context.newIssue().forRule(xmlIssue.getRuleKey());
NewIssueLocation location = newIssue.newLocation()
.on(sourceCode.getInputFile().wrapped())
.message(xmlIssue.getMessage());
if (xmlIssue.getLine() != null) {
location.at(sourceCode.getInputFile().selectLine(xmlIssue.getLine()));
}
newIssue.at(location).save();
}
}
示例10: saveMetrics
import org.sonar.api.batch.sensor.issue.NewIssueLocation; //导入方法依赖的package包/类
private static void saveMetrics(SensorContext context, WebSourceCode sourceCode) {
InputFile inputFile = sourceCode.inputFile();
saveComplexityDistribution(context, sourceCode);
for (Map.Entry<Metric<Integer>, Integer> entry : sourceCode.getMeasures().entrySet()) {
context.<Integer>newMeasure()
.on(inputFile)
.forMetric(entry.getKey())
.withValue(entry.getValue())
.save();
}
for (WebIssue issue : sourceCode.getIssues()) {
NewIssue newIssue = context.newIssue()
.forRule(issue.ruleKey())
.gap(issue.cost());
Integer line = issue.line();
NewIssueLocation location = newIssue.newLocation()
.on(inputFile)
.message(issue.message());
if (line != null) {
location.at(inputFile.selectLine(line));
}
newIssue.at(location);
newIssue.save();
}
}
示例11: 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;
}