Search in sources :

Example 6 with ActiveRules

use of org.sonar.api.batch.rule.ActiveRules in project sonarqube by SonarSource.

the class SensorOptimizerTest method should_optimize_on_repository.

@Test
public void should_optimize_on_repository() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().createIssuesForRuleRepositories("squid");
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    ActiveRules activeRules = new ActiveRulesBuilder().create(RuleKey.of("repo1", "foo")).activate().build();
    optimizer = new SensorOptimizer(fs, activeRules, settings);
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    activeRules = new ActiveRulesBuilder().create(RuleKey.of("repo1", "foo")).activate().create(RuleKey.of("squid", "rule")).activate().build();
    optimizer = new SensorOptimizer(fs, activeRules, settings);
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : ActiveRulesBuilder(org.sonar.api.batch.rule.internal.ActiveRulesBuilder) DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) ActiveRules(org.sonar.api.batch.rule.ActiveRules) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 ActiveRules (org.sonar.api.batch.rule.ActiveRules)6 ActiveRulesBuilder (org.sonar.api.batch.rule.internal.ActiveRulesBuilder)3 File (java.io.File)1 ActiveRule (org.sonar.api.batch.rule.ActiveRule)1 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)1 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)1 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)1 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)1 ActiveRulesPublisher (org.sonar.scanner.report.ActiveRulesPublisher)1 LoadedActiveRule (org.sonar.scanner.rule.LoadedActiveRule)1 ModuleQProfiles (org.sonar.scanner.rule.ModuleQProfiles)1