use of org.sonarsource.sonarlint.core.analysis.sonarapi.ActiveRulesAdapter in project sonarlint-core by SonarSource.
the class SensorOptimizerTests method should_optimize_on_repository.
@Test
void should_optimize_on_repository() {
var descriptor = new DefaultSensorDescriptor().createIssuesForRuleRepositories("squid");
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
var ruleAnotherRepo = mock(ActiveRuleAdapter.class);
when(ruleAnotherRepo.ruleKey()).thenReturn(RuleKey.of("repo1", "foo"));
ActiveRules activeRules = new ActiveRulesAdapter(List.of(ruleAnotherRepo));
optimizer = new SensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
var ruleSquid = mock(ActiveRuleAdapter.class);
when(ruleSquid.ruleKey()).thenReturn(RuleKey.of("squid", "rule"));
activeRules = new ActiveRulesAdapter(asList(ruleSquid, ruleAnotherRepo));
optimizer = new SensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of org.sonarsource.sonarlint.core.analysis.sonarapi.ActiveRulesAdapter in project sonarlint-core by SonarSource.
the class ModuleContainer method analyze.
public AnalysisResults analyze(AnalysisConfiguration configuration, Consumer<Issue> issueListener, ProgressMonitor progress) {
var analysisContainer = new AnalysisContainer(this, progress);
analysisContainer.add(configuration);
analysisContainer.add(new IssueListenerHolder(issueListener));
analysisContainer.add(new ActiveRulesAdapter(configuration.activeRules().stream().map(ActiveRuleAdapter::new).collect(Collectors.toList())));
var defaultAnalysisResult = new AnalysisResults();
analysisContainer.add(defaultAnalysisResult);
analysisContainer.execute();
return defaultAnalysisResult;
}
Aggregations