use of org.sonar.api.batch.sensor.SensorContext in project sonarlint-core by SonarSource.
the class GlobalSensor method execute.
@Override
public void execute(final SensorContext context) {
long timeBefore = clock.millis();
RuleKey globalRuleKey = RuleKey.of(GlobalRulesDefinition.KEY, GlobalRulesDefinition.RULE_KEY);
ActiveRule activeGlobalRule = context.activeRules().find(globalRuleKey);
if (activeGlobalRule != null) {
Stream.of("stringParam", "textParam", "intParam", "boolParam", "floatParam", "enumParam", "enumListParam", "multipleIntegersParam").map(k -> Arrays.asList(k, activeGlobalRule.param(k))).forEach(kv -> LOGGER.info("Param {} has value {}", kv.get(0), kv.get(1)));
} else {
LOGGER.error("Rule is not active");
}
for (InputFile f : context.fileSystem().inputFiles(context.fileSystem().predicates().all())) {
NewIssue newIssue = context.newIssue();
newIssue.forRule(globalRuleKey).at(newIssue.newLocation().on(f).message("Issue number " + GlobalExtension.getInstance().getAndInc())).save();
}
long timeAfter = clock.millis();
LOGGER.info(String.format("Executed Global Sensor in %d ms", timeAfter - timeBefore));
}
Aggregations