本文整理汇总了Java中org.sonar.api.batch.fs.InputComponent类的典型用法代码示例。如果您正苦于以下问题:Java InputComponent类的具体用法?Java InputComponent怎么用?Java InputComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputComponent类属于org.sonar.api.batch.fs包,在下文中一共展示了InputComponent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: store
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@Override
public void store(Issue issue) {
InputComponent inputComponent = issue.primaryLocation().inputComponent();
DefaultRule rule = validateRule(issue);
ActiveRule activeRule = activeRules.find(issue.ruleKey());
if (activeRule == null) {
// rule does not exist or is not enabled -> ignore the issue
return;
}
String primaryMessage = Strings.isNullOrEmpty(issue.primaryLocation().message()) ? rule.name() : issue.primaryLocation().message();
org.sonar.api.batch.rule.Severity overriddenSeverity = issue.overriddenSeverity();
String severity = overriddenSeverity != null ? overriddenSeverity.name() : activeRule.severity();
String type = rule.type();
DefaultClientIssue newIssue = new DefaultClientIssue(severity, type, activeRule, rules.find(activeRule.ruleKey()), primaryMessage, issue.primaryLocation().textRange(),
inputComponent.isFile() ? ((SonarLintInputFile) inputComponent).getClientInputFile() : null, issue.flows());
issueListener.handle(newIssue);
}
开发者ID:instalint-org,项目名称:instalint,代码行数:21,代码来源:DefaultSensorStorage.java
示例2: incrementMetrics
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private void incrementMetrics(final XMLReportFinding xanFinding,
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project, final InputFile inputFile) {
final Severity severity = SensorUtil.mkSeverity(xanFinding);
final List<Metric<Serializable>> metrics = mkMetrics(xanFinding.getProblemType());
for (final Metric<Serializable> metric : metrics) {
incrementValueForFileAndProject(metric, inputFile, project, metricValuesAccu);
}
final String matchCode = xanFinding.getMatchCode();
if ("NOT".equals(matchCode)) {
incrementValueForFileAndProject(XanitizerMetrics.getMetricForNewXanFindings(),
inputFile, project, metricValuesAccu);
}
final Metric<Serializable> metricForSeverity = XanitizerMetrics
.getMetricForSeverity(severity);
if (metricForSeverity != null) {
incrementValueForFileAndProject(metricForSeverity, inputFile, project,
metricValuesAccu);
}
}
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:24,代码来源:XanitizerSensor.java
示例3: processIssue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private void processIssue(Reporter report, PostJobIssue issue) {
boolean reportedInline = false;
InputComponent inputComponent = issue.inputComponent();
String revision = null;
if (inputComponent != null && inputComponent.isFile() && issue.line() != null) {
revision = commitFacade.getRevisionForLine((InputFile) inputComponent, issue.line());
reportedInline = gitLabPluginConfiguration.tryReportIssuesInline() && revision != null;
}
LOG.debug("Revision for issue {} {} {}", issue, revision, reportedInline);
LOG.debug("inputComponent {} {}", inputComponent, issue.line());
String url = commitFacade.getGitLabUrl(revision, inputComponent, issue.line());
String src = commitFacade.getSrc(inputComponent);
String ruleLink = commitFacade.getRuleLink(issue.ruleKey().toString());
report.process(issue, revision, url, src, ruleLink, reportedInline, true);
}
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:19,代码来源:CommitIssuePostJob.java
示例4: processIssues
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private Map<InputFile, Map<Integer, StringBuilder>> processIssues(GlobalReport report, Iterable<PostJobIssue> issues) {
Map<InputFile, Map<Integer, StringBuilder>> commentToBeAddedByFileAndByLine = new HashMap<>();
StreamSupport.stream(issues.spliterator(), false)
.filter(PostJobIssue::isNew)
// SONARGITUB-13 Ignore issues on files not modified by the P/R
.filter(i -> {
InputComponent inputComponent = i.inputComponent();
return inputComponent == null ||
!inputComponent.isFile() ||
pullRequestFacade.hasFile((InputFile) inputComponent);
})
.sorted(ISSUE_COMPARATOR)
.forEach(i -> processIssue(report, commentToBeAddedByFileAndByLine, i));
return commentToBeAddedByFileAndByLine;
}
开发者ID:SonarSource,项目名称:sonar-github,代码行数:18,代码来源:PullRequestIssuePostJob.java
示例5: testShouldIncludeIssue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@Test
public void testShouldIncludeIssue() {
Set<RuleKey> er = new HashSet<>();
InputComponent ic = new DefaultInputFile("module", "some/path");
assertFalse(
SonarQubeCollector.shouldIncludeIssue(
new DefaultIssue().setNew(false).setInputComponent(ic), ipr, false, er
)
);
assertTrue(
SonarQubeCollector.shouldIncludeIssue(
new DefaultIssue().setNew(false).setInputComponent(ic), ipr, true, er
)
);
assertTrue(
SonarQubeCollector.shouldIncludeIssue(
new DefaultIssue().setNew(true).setInputComponent(ic), ipr, false, er
)
);
assertTrue(
SonarQubeCollector.shouldIncludeIssue(
new DefaultIssue().setNew(true).setInputComponent(ic), ipr, true, er
)
);
}
开发者ID:AmadeusITGroup,项目名称:sonar-stash,代码行数:27,代码来源:SonarQubeCollectorTest.java
示例6: generateIssueForFinding
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private void generateIssueForFinding(final XMLReportFinding xanFinding,
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project, final SensorContext sensorContext) {
if (!activeXanRuleNames.contains(xanFinding.getProblemType().name())) {
LOG.debug(SKIP_FINDING_MESSAGE + xanFinding.getFindingID()
+ ": Rule for corresponding problem type is disabled.");
return;
}
final InputFile inputFile = mkInputFileOrNull(xanFinding.getLocation(), sensorContext);
if (inputFile == null) {
/*
* Do not generate issues without code location
*/
LOG.debug(SKIP_FINDING_MESSAGE + xanFinding.getFindingID()
+ ": Corresponding file could not be found in project.");
return;
}
final boolean issueCreated = createNewIssue(inputFile, xanFinding, sensorContext);
if (issueCreated) {
incrementMetrics(xanFinding, metricValuesAccu, project, inputFile);
}
}
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:28,代码来源:XanitizerSensor.java
示例7: initializeMetrics
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void initializeMetrics(
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final DefaultInputModule project) {
for (Metric<Serializable> metric : new XanitizerMetrics().getMetrics()) {
initializeMetric(metricValuesAccu, project, metric);
}
}
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:10,代码来源:XanitizerSensor.java
示例8: initializeMetric
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private void initializeMetric(
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
final InputComponent resource, final Metric<Serializable> metric) {
Map<InputComponent, Integer> innerMap = new LinkedHashMap<>();
innerMap.put(resource, 0);
metricValuesAccu.put(metric, innerMap);
}
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:8,代码来源:XanitizerSensor.java
示例9: incrementValue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private static void incrementValue(final Metric<Serializable> metric,
final InputComponent resource,
final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu) {
final Map<InputComponent, Integer> innerMap = metricValuesAccu.computeIfAbsent(metric,
k -> new LinkedHashMap<>());
final Integer value = innerMap.computeIfAbsent(resource, k -> 0);
innerMap.put(resource, 1 + value);
}
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:10,代码来源:XanitizerSensor.java
示例10: getGitLabUrl
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@CheckForNull
public String getGitLabUrl(@Nullable String revision, @Nullable InputComponent inputComponent, @Nullable Integer issueLine) {
if (inputComponent instanceof InputPath) {
String path = getPath((InputPath) inputComponent);
return gitLabWrapper.getGitLabUrl(revision, path, issueLine);
}
return null;
}
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:9,代码来源:CommitFacade.java
示例11: getSrc
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@CheckForNull
public String getSrc(@Nullable InputComponent inputComponent) {
if (inputComponent instanceof InputPath) {
return getPath((InputPath) inputComponent);
}
return null;
}
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:8,代码来源:CommitFacade.java
示例12: getStreamPostJobIssue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private Stream<PostJobIssue> getStreamPostJobIssue(Iterable<PostJobIssue> issues) {
return StreamSupport.stream(issues.spliterator(), false).filter(p -> gitLabPluginConfiguration.allIssues() || p.isNew()).filter(i -> {
InputComponent inputComponent = i.inputComponent();
if (gitLabPluginConfiguration.onlyIssueFromCommitLine()) {
return onlyIssueFromCommitLine(i);
}
return !gitLabPluginConfiguration.onlyIssueFromCommitFile() || inputComponent == null || !inputComponent.isFile() || commitFacade.hasFile((InputFile) inputComponent);
});
}
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:10,代码来源:CommitIssuePostJob.java
示例13: processIssue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
private void processIssue(GlobalReport report, Map<InputFile, Map<Integer, StringBuilder>> commentToBeAddedByFileAndByLine, PostJobIssue issue) {
boolean reportedInline = false;
InputComponent inputComponent = issue.inputComponent();
if (gitHubPluginConfiguration.tryReportIssuesInline() && inputComponent != null && inputComponent.isFile()) {
reportedInline = tryReportInline(commentToBeAddedByFileAndByLine, issue, (InputFile) inputComponent);
}
report.process(issue, pullRequestFacade.getGithubUrl(inputComponent, issue.line()), reportedInline);
}
开发者ID:SonarSource,项目名称:sonar-github,代码行数:9,代码来源:PullRequestIssuePostJob.java
示例14: getGithubUrl
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@CheckForNull
public URL getGithubUrl(@Nullable InputComponent inputComponent, @Nullable Integer issueLine) {
if (inputComponent instanceof InputPath) {
String path = getPath((InputPath) inputComponent);
URL url1 = ghRepo.getHtmlUrl();
try {
return new URI(url1.getProtocol(), null, url1.getHost(), url1.getPort(),
url1.getFile() + "/blob/" + pr.getHead().getSha() + "/" + path, null, issueLine != null ? ("L" + issueLine) : "").toURL();
} catch (MalformedURLException | URISyntaxException e) {
LOG.error("Invalid URL", e);
}
}
return null;
}
开发者ID:SonarSource,项目名称:sonar-github,代码行数:15,代码来源:PullRequestFacade.java
示例15: addIssue
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
protected void addIssue(String ruleKey, String message, InputComponent inputComponent) {
LOGGER.info("Adding issue: " + ruleKey + " " + message);
NewIssue newIssue = context
.newIssue()
.forRule(RuleKey.of(CheckList.REPOSITORY_KEY, ruleKey));
newIssue.at(newLocation(inputComponent, newIssue, message)).save();
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:9,代码来源:ProjectChecks.java
示例16: isProjectWide
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
public static boolean isProjectWide(PostJobIssue issue) {
InputComponent ic = issue.inputComponent();
if (!(ic instanceof InputModule)) {
return false;
}
InputModule im = (InputModule) ic;
if (im.key() == null) {
return false;
}
return CharMatcher.is(':').countIn(im.key()) == 0;
}
开发者ID:AmadeusITGroup,项目名称:sonar-stash,代码行数:12,代码来源:StashPluginUtils.java
示例17: getIssuePath
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@Override
public String getIssuePath(PostJobIssue issue) {
InputComponent ip = issue.inputComponent();
if (ip == null || !ip.isFile()) {
return null;
}
InputFile inputFile = (InputFile) ip;
File baseDir = config
.getRepositoryRoot()
.orElse(projectBaseDir);
return new PathResolver().relativePath(baseDir, inputFile.file());
}
开发者ID:AmadeusITGroup,项目名称:sonar-stash,代码行数:16,代码来源:StashRequestFacade.java
示例18: getIssuePath
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
@Override
public String getIssuePath(PostJobIssue issue) {
InputComponent ic = issue.inputComponent();
if (ic == null) {
return null;
}
return ((InputFile) ic).relativePath();
}
开发者ID:AmadeusITGroup,项目名称:sonar-stash,代码行数:9,代码来源:DummyIssuePathResolver.java
示例19: createMissingIssues
import org.sonar.api.batch.fs.InputComponent; //导入依赖的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();
}
}
开发者ID:SonarSource,项目名称:sonar-lits,代码行数:34,代码来源:DumpPhase.java
示例20: getOn
import org.sonar.api.batch.fs.InputComponent; //导入依赖的package包/类
public InputComponent getOn() {
return on;
}
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:4,代码来源:Location.java
注:本文中的org.sonar.api.batch.fs.InputComponent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论