use of org.sonarsource.sonarlint.core.analysis.api.ActiveRule in project sonarlint-core by SonarSource.
the class StandaloneSonarLintEngineImpl method identifyActiveRules.
private Collection<ActiveRule> identifyActiveRules(StandaloneAnalysisConfiguration configuration) {
Set<String> excludedRules = configuration.excludedRules().stream().map(RuleKey::toString).collect(toSet());
Set<String> includedRules = configuration.includedRules().stream().map(RuleKey::toString).filter(r -> !excludedRules.contains(r)).collect(toSet());
Collection<SonarLintRuleDefinition> filteredActiveRules = new ArrayList<>();
filteredActiveRules.addAll(allRulesDefinitionsByKey.values().stream().filter(SonarLintRuleDefinition::isActiveByDefault).filter(isExcludedByConfiguration(excludedRules)).collect(Collectors.toList()));
filteredActiveRules.addAll(allRulesDefinitionsByKey.values().stream().filter(r -> !r.isActiveByDefault()).filter(isIncludedByConfiguration(includedRules)).collect(Collectors.toList()));
return filteredActiveRules.stream().map(rd -> {
var activeRule = new ActiveRule(rd.getKey(), rd.getLanguage().getLanguageKey());
Map<String, String> effectiveParams = new HashMap<>(rd.getDefaultParams());
Optional.ofNullable(configuration.ruleParameters().get(RuleKey.parse(rd.getKey()))).ifPresent(effectiveParams::putAll);
activeRule.setParams(effectiveParams);
return activeRule;
}).collect(Collectors.toList());
}
Aggregations