use of org.sonar.api.batch.rule.internal.ActiveRulesBuilder in project sonarqube by SonarSource.
the class ModuleSensorOptimizerTest 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().addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("repo1", "foo")).build()).build();
optimizer = new ModuleSensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
activeRules = new ActiveRulesBuilder().addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("repo1", "foo")).build()).addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("squid", "rule")).build()).build();
optimizer = new ModuleSensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of org.sonar.api.batch.rule.internal.ActiveRulesBuilder in project sonarqube by SonarSource.
the class ModuleSensorContextTest method prepare.
@Before
public void prepare() throws Exception {
activeRules = new ActiveRulesBuilder().build();
fs = new DefaultFileSystem(temp.newFolder().toPath());
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
settings = new MapSettings();
sensorStorage = mock(SensorStorage.class);
branchConfiguration = mock(BranchConfiguration.class);
runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
}
Aggregations