Search in sources :

Example 16 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core by SonarSource.

the class SensorOptimizerTest method should_run_analyzer_with_no_metadata.

@Test
public void should_run_analyzer_with_no_metadata() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 17 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core by SonarSource.

the class SensorOptimizerTest method should_optimize_on_settings.

@Test
public void should_optimize_on_settings() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().requireProperty("sonar.foo.reportPath");
    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
    settings.setProperty("sonar.foo.reportPath", "foo");
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 18 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core 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.asConfig());
    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.asConfig());
    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)

Example 19 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core by SonarSource.

the class NewSensorsExecutor method execute.

@Override
public void execute() {
    for (Sensor sensor : sort(asList(sensors))) {
        progress.checkCancel();
        DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
        sensor.describe(descriptor);
        if (sensorOptimizer.shouldExecute(descriptor)) {
            executeSensor(context, sensor, descriptor);
        }
    }
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Sensor(org.sonar.api.batch.sensor.Sensor)

Example 20 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonar-web by SonarSource.

the class WebSensorTest method testDescriptor.

@Test
public void testDescriptor() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    sensor.describe(descriptor);
    assertThat(descriptor.name()).isEqualTo("Web");
    assertThat(descriptor.languages()).containsOnly("web");
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Aggregations

DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)28 Test (org.junit.Test)26 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)10 SonarRuntime (org.sonar.api.SonarRuntime)3 ActiveRules (org.sonar.api.batch.rule.ActiveRules)3 CheckFactory (org.sonar.api.batch.rule.CheckFactory)3 ActiveRulesBuilder (org.sonar.api.batch.rule.internal.ActiveRulesBuilder)3 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)3 Test (org.junit.jupiter.api.Test)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 Sensor (org.sonar.api.batch.sensor.Sensor)1 MapSettings (org.sonar.api.config.internal.MapSettings)1