use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonar-web by SonarSource.
the class WebSensorTest method setUp.
@Before
public void setUp() throws Exception {
WebRulesDefinition rulesDefinition = new WebRulesDefinition();
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
RulesDefinition.Repository repository = context.repository(WebRulesDefinition.REPOSITORY_KEY);
List<NewActiveRule> ar = new ArrayList<>();
for (RulesDefinition.Rule rule : repository.rules()) {
ar.add(new ActiveRulesBuilder().create(RuleKey.of(WebRulesDefinition.REPOSITORY_KEY, rule.key())));
}
ActiveRules activeRules = new DefaultActiveRules(ar);
CheckFactory checkFactory = new CheckFactory(activeRules);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
sensor = new WebSensor(new NoSonarFilter(), fileLinesContextFactory, checkFactory);
tester = SensorContextTester.create(TEST_DIR);
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonar-web by SonarSource.
the class HtmlSensorTest method test_descriptor_sonarqube_9_3_reflection_failure.
@Test
public void test_descriptor_sonarqube_9_3_reflection_failure() {
DefaultSensorDescriptor sensorDescriptor = new DefaultSensorDescriptor();
SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(9, 3), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
new HtmlSensor(sonarRuntime, null, null, new CheckFactory(new DefaultActiveRules(Collections.emptyList()))).describe(sensorDescriptor);
assertThat(sensorDescriptor.name()).isEqualTo("HTML");
assertThat(sensorDescriptor.languages()).isEmpty();
assertTrue(logTester.logs().contains("Could not call SensorDescriptor.processesFilesIndependently() method"));
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonar-web by SonarSource.
the class HtmlSensorTest method test_descriptor_sonarlint.
@Test
public void test_descriptor_sonarlint() {
DefaultSensorDescriptor sensorDescriptor = new DefaultSensorDescriptor();
SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarLint(Version.create(6, 5));
new HtmlSensor(sonarRuntime, null, null, new CheckFactory(new DefaultActiveRules(Collections.emptyList()))).describe(sensorDescriptor);
assertThat(sensorDescriptor.name()).isEqualTo("HTML");
assertThat(sensorDescriptor.languages()).isEmpty();
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonar-web by SonarSource.
the class HtmlSensorTest method setUp.
@Before
public void setUp() {
HtmlRulesDefinition rulesDefinition = new HtmlRulesDefinition();
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
RulesDefinition.Repository repository = context.repository(HtmlRulesDefinition.REPOSITORY_KEY);
List<NewActiveRule> ar = new ArrayList<>();
for (RulesDefinition.Rule rule : repository.rules()) {
ar.add(new NewActiveRule.Builder().setRuleKey(RuleKey.of(HtmlRulesDefinition.REPOSITORY_KEY, rule.key())).build());
}
ActiveRules activeRules = new DefaultActiveRules(ar);
CheckFactory checkFactory = new CheckFactory(activeRules);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
final SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(8, 9), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
sensor = new HtmlSensor(sonarRuntime, new NoSonarFilter(), fileLinesContextFactory, checkFactory);
tester = SensorContextTester.create(TEST_DIR).setRuntime(sonarRuntime);
}
use of org.sonar.api.batch.rule.internal.DefaultActiveRules in project sonarqube by SonarSource.
the class ActiveRulesProvider method provide.
@Bean("ActiveRules")
public DefaultActiveRules provide(ActiveRulesLoader loader, QualityProfiles qProfiles) {
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
DefaultActiveRules activeRules = load(loader, qProfiles);
profiler.stopInfo();
return activeRules;
}
Aggregations