本文整理汇总了Java中org.sonar.api.batch.sensor.issue.NewIssue.at方法的典型用法代码示例。如果您正苦于以下问题:Java NewIssue.at方法的具体用法?Java NewIssue.at怎么用?Java NewIssue.at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.sensor.issue.NewIssue
的用法示例。
在下文中一共展示了NewIssue.at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: saveIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的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();
}
示例3: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
final Set<String> cycles = collectCycles(javaPackage);
getContext().<Integer> newMeasure().forMetric(JdependMetrics.PACKAGE_DEPENDENCY_CYCLES).on(packageInfoFile)
.withValue(cycles.size()).save();
if (!isActive()) {
return;
}
if (cycles.size() > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1))
.message(createMessage(cycles)));
issue.save();
}
}
示例4: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
final int classcount = javaPackage.getClassCount();
getContext().<Integer> newMeasure().forMetric(JdependMetrics.NUMBER_OF_CLASSES_AND_INTERFACES)
.on(packageInfoFile).withValue(classcount).save();
if (!isActive()) {
return;
}
if (classcount > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1))
.message("Too many classes and interfaces (allowed: " + maximum + ", actual: "
+ javaPackage.getClassCount() + ")"));
issue.save();
}
}
示例5: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
final int efferentCoupling = javaPackage.efferentCoupling();
getContext().<Integer> newMeasure().forMetric(JdependMetrics.EFFERENT_COUPLINGS).on(packageInfoFile)
.withValue(efferentCoupling).save();
if (!isActive()) {
return;
}
if (efferentCoupling > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1))
.message("Too much efferent coupling (allowed: " + maximum + ", actual: "
+ javaPackage.getClassCount() + ")"));
issue.save();
}
}
示例6: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
final int afferentCoupling = javaPackage.afferentCoupling();
getContext().<Integer> newMeasure().forMetric(JdependMetrics.AFFERENT_COUPLINGS).on(packageInfoFile)
.withValue(afferentCoupling).save();
if (!isActive()) {
return;
}
if (afferentCoupling > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1))
.message("Too much afferent coupling (allowed: " + maximum + ", actual: "
+ javaPackage.getClassCount() + ")"));
issue.save();
}
}
示例7: saveIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的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();
}
示例8: 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();
}
示例9: saveViolations
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的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();
}
}
}
示例10: newIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private boolean newIssue(final SensorContext context, final ActiveRule rule, final External<Location> model,
final String message) {
final Location location = model.getExternal();
if (location == null) {
LOGGER.debug("Rule {} triggered, but {} did not contain a location to register issue", rule.ruleKey(),
model);
return false;
} else {
LOGGER.debug("Rule {} triggered, registering issue on {}", rule.ruleKey(), model);
final NewIssue issue = context.newIssue().forRule(rule.ruleKey());
issue.at(issue.newLocation().on(location.getOn()).at(location.getAt()).message(message));
issue.save();
return true;
}
}
示例11: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
if (!isActive()) {
return;
}
final int distance = Math.round(javaPackage.distance() * 100);
if (distance > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1)).message(
"Too much distance from the main sequence (allowed: " + maximum + ", actual: " + distance + ")"));
issue.save();
}
}
示例12: execute
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void execute(final JavaPackage javaPackage, final InputFile packageInfoFile) {
if (!isActive()) {
return;
}
final int instability = Math.round(javaPackage.instability() * 100);
if (instability > maximum) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(packageInfoFile).at(packageInfoFile.selectLine(1))
.message("Too much instability (allowed: " + maximum + ", actual: " + instability + ")"));
issue.save();
}
}
示例13: saveMetrics
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的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();
}
}
示例14: 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;
}
示例15: registerIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
/**
* Register an issue.
*
* @param inputFile
* input file
* @param message
* issue message
*/
protected void registerIssue(final InputFile inputFile, final String message) {
final NewIssue issue = getContext().newIssue().forRule(getKey());
issue.at(issue.newLocation().on(inputFile).at(inputFile.selectLine(1)).message(message));
issue.save();
}