当前位置: 首页>>代码示例>>Java>>正文


Java DefaultSensorDescriptor类代码示例

本文整理汇总了Java中org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor的典型用法代码示例。如果您正苦于以下问题:Java DefaultSensorDescriptor类的具体用法?Java DefaultSensorDescriptor怎么用?Java DefaultSensorDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultSensorDescriptor类属于org.sonar.api.batch.sensor.internal包,在下文中一共展示了DefaultSensorDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldExecute

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
/**
 * Decide if the given Sensor should be executed.
 */
public boolean shouldExecute(DefaultSensorDescriptor descriptor) {
  if (!fsCondition(descriptor)) {
    LOG.debug("'{}' skipped because there is no related file in current project", descriptor.name());
    return false;
  }
  if (!activeRulesCondition(descriptor)) {
    LOG.debug("'{}' skipped because there is no related rule activated in the quality profile", descriptor.name());
    return false;
  }
  if (!settingsCondition(descriptor)) {
    LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
    return false;
  }
  return true;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:19,代码来源:SensorOptimizer.java

示例2: should_optimize_on_repository

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@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();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:24,代码来源:SensorOptimizerTest.java

示例3: sensor_descriptor

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void sensor_descriptor() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    createSensor().describe(descriptor);

    assertThat(descriptor.name()).isEqualTo("1C 7.7 sensor");
    assertThat(descriptor.languages()).containsOnly("1c 7.7");
    assertThat(descriptor.type()).isEqualTo(Type.MAIN);
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:10,代码来源:OneCSensorTest.java

示例4: describe

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void describe() {
	DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
	sensor.describe(descriptor);
	Assert.assertEquals("Package Analyzer Sensor (TEST)", descriptor.name());
	Assert.assertEquals(Arrays.asList("TEST"), descriptor.languages());
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:8,代码来源:AbstractSensorTest.java

示例5: execute

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Override
public void execute() {
  for (Sensor sensor : sort(asList(sensors))) {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    sensor.describe(descriptor);
    if (sensorOptimizer.shouldExecute(descriptor)) {
      executeSensor(context, sensor, descriptor);
    }
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:11,代码来源:NewSensorsExecutor.java

示例6: settingsCondition

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
private boolean settingsCondition(DefaultSensorDescriptor descriptor) {
  if (!descriptor.properties().isEmpty()) {
    for (String propertyKey : descriptor.properties()) {
      if (!settings.hasKey(propertyKey)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:11,代码来源:SensorOptimizer.java

示例7: activeRulesCondition

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
private boolean activeRulesCondition(DefaultSensorDescriptor descriptor) {
  if (!descriptor.ruleRepositories().isEmpty()) {
    for (String repoKey : descriptor.ruleRepositories()) {
      if (!activeRules.findByRepository(repoKey).isEmpty()) {
        return true;
      }
    }
    return false;
  }
  return true;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:12,代码来源:SensorOptimizer.java

示例8: fsCondition

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
private boolean fsCondition(DefaultSensorDescriptor descriptor) {
  if (!descriptor.languages().isEmpty() || descriptor.type() != null) {
    FilePredicate langPredicate = descriptor.languages().isEmpty() ? fs.predicates().all() : fs.predicates().hasLanguages(descriptor.languages());

    FilePredicate typePredicate = descriptor.type() == null ? fs.predicates().all() : fs.predicates().hasType(descriptor.type());
    return fs.hasFiles(fs.predicates().and(langPredicate, typePredicate));
  }
  return true;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:10,代码来源:SensorOptimizer.java

示例9: SensorWrapper

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
public SensorWrapper(Sensor newSensor, SensorContext adaptor, SensorOptimizer optimizer) {
  this.wrappedSensor = newSensor;
  this.optimizer = optimizer;
  descriptor = new DefaultSensorDescriptor();
  newSensor.describe(descriptor);
  this.adaptor = adaptor;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:8,代码来源:SensorWrapper.java

示例10: should_optimize_on_language

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void should_optimize_on_language() {
  DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor()
    .onlyOnLanguages("java", "php");
  assertThat(optimizer.shouldExecute(descriptor)).isFalse();

  fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setLanguage("java").build());
  assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:10,代码来源:SensorOptimizerTest.java

示例11: should_optimize_on_type

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void should_optimize_on_type() {
  DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor()
    .onlyOnFileType(InputFile.Type.MAIN);
  assertThat(optimizer.shouldExecute(descriptor)).isFalse();

  fs.add(new TestInputFileBuilder("foo", "tests/FooTest.java").setType(InputFile.Type.TEST).build());
  assertThat(optimizer.shouldExecute(descriptor)).isFalse();

  fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setType(InputFile.Type.MAIN).build());
  assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:13,代码来源:SensorOptimizerTest.java

示例12: should_optimize_on_both_type_and_language

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void should_optimize_on_both_type_and_language() {
  DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor()
    .onlyOnLanguages("java", "php")
    .onlyOnFileType(InputFile.Type.MAIN);
  assertThat(optimizer.shouldExecute(descriptor)).isFalse();

  fs.add(new TestInputFileBuilder("foo", "tests/FooTest.java").setLanguage("java").setType(InputFile.Type.TEST).build());
  fs.add(new TestInputFileBuilder("foo", "src/Foo.cbl").setLanguage("cobol").setType(InputFile.Type.MAIN).build());
  assertThat(optimizer.shouldExecute(descriptor)).isFalse();

  fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setLanguage("java").setType(InputFile.Type.MAIN).build());
  assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:15,代码来源:SensorOptimizerTest.java

示例13: should_optimize_on_settings

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@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();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:10,代码来源:SensorOptimizerTest.java

示例14: should_create_a_valid_sensor_descriptor

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void should_create_a_valid_sensor_descriptor() {
  DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
  createCssSquidSensor().describe(descriptor);
  assertThat(descriptor.name()).isEqualTo("CSS Analyzer Sensor");
  assertThat(descriptor.languages()).containsOnly("css");
  assertThat(descriptor.type()).isEqualTo(InputFile.Type.MAIN);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:9,代码来源:CssAnalyzerSensorTest.java

示例15: should_create_a_valid_sensor_descriptor

import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; //导入依赖的package包/类
@Test
public void should_create_a_valid_sensor_descriptor() {
  DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
  createEmbeddedCssSquidSensor().describe(descriptor);
  assertThat(descriptor.name()).isEqualTo("Embedded CSS Analyzer Sensor");
  assertThat(descriptor.languages()).isEmpty();
  assertThat(descriptor.type()).isNull();
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:9,代码来源:EmbeddedCssAnalyzerSensorTest.java


注:本文中的org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。