use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class OneIssuePerModuleSensor method analyse.
private void analyse(SensorContext context, String language, String repo) {
RuleKey ruleKey = RuleKey.of(repo, RULE_KEY);
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(context.module()).message("This issue is generated on each module")).save();
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class OneIssuePerUnknownFileSensor method execute.
@Override
public void execute(SensorContext context) {
RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
FilePredicate unknownFilesPredicate = context.fileSystem().predicates().matchesPathPattern("**/*.unknown");
Iterable<InputFile> unknownFiles = context.fileSystem().inputFiles(unknownFilesPredicate);
unknownFiles.forEach(inputFile -> {
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(inputFile).message("This issue is generated on each file with extension 'unknown'")).save();
});
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class OneVulnerabilityIssuePerModuleSensor method analyse.
private void analyse(SensorContext context, String repo) {
RuleKey ruleKey = RuleKey.of(repo, RULE_KEY);
NewIssue newIssue = context.newIssue();
newIssue.forRule(ruleKey).at(newIssue.newLocation().on(context.module()).message("This issue is generated on each module")).save();
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class ActiveRuleKeyTest method of.
@Test
public void of() {
RuleKey ruleKey = RuleKey.of("xoo", "R1");
ActiveRuleKey key = ActiveRuleKey.of("P1", ruleKey);
assertThat(key.qProfile()).isEqualTo("P1");
assertThat(key.ruleKey()).isSameAs(ruleKey);
assertThat(key.toString()).isEqualTo("P1:xoo:R1");
}
use of org.sonar.api.rule.RuleKey in project sonarqube by SonarSource.
the class CommonRule method processFile.
@CheckForNull
public DefaultIssue processFile(Component file, String fileLanguage) {
DefaultIssue issue = null;
RuleKey ruleKey = RuleKey.of(commonRepositoryForLang(fileLanguage), key);
Optional<ActiveRule> activeRule = activeRulesHolder.get(ruleKey);
if (activeRule.isPresent()) {
CommonRuleIssue cri = doProcessFile(file, activeRule.get());
if (cri != null) {
issue = new DefaultIssue();
issue.setGap(cri.effortToFix);
issue.setMessage(cri.message);
issue.setRuleKey(ruleKey);
issue.setSeverity(activeRule.get().getSeverity());
issue.setLine(null);
issue.setChecksum("");
}
}
return issue;
}
Aggregations