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


Java ActiveRules类代码示例

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


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

示例1: active

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void active() {
	final ActiveRules activeRules = Mockito.mock(ActiveRules.class);
	sensorContext.setActiveRules(activeRules);
	Mockito.when(activeRules.find(RuleKey.of("package-analyzer-test-no", "test"))).thenReturn(null);
	Mockito.when(activeRules.find(RuleKey.of("package-analyzer-test-yes", "test"))).thenReturn(activeRule);

	// Model
	final Model<Location> model = new Model<>();
	model.addPackage("packageA", location("packageA/package-info.java"));

	// Check only no issue, because test-no:test is not active
	subject.scanModel(sensorContext, "test-no", model);
	Assert.assertEquals(0, sensorContext.allIssues().size());

	// Check only one issue, because test-yes:test is active
	subject.scanModel(sensorContext, "test-yes", model);
	Assert.assertEquals(1, sensorContext.allIssues().size());
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:20,代码来源:AbstractPackageAnalyzerRuleTest.java

示例2: should_optimize_on_repository

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的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: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  inputFile("parsingError.css");

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(CheckList.CSS_REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createCssSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:CssAnalyzerSensorTest.java

示例4: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  inputFile("parsingError.less");

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(CheckList.LESS_REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createLessSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:LessAnalyzerSensorTest.java

示例5: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  inputFile("parsingError.scss");

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(CheckList.SCSS_REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createScssSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:ScssAnalyzerSensorTest.java

示例6: XanitizerSensor

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
/**
 * The Xanitizer sensor
 * 
 * @param javaResourceLocator
 * @param settings
 * @param activeRules
 * @param sensorContext
 */
public XanitizerSensor(final JavaResourceLocator javaResourceLocator,
		final ActiveRules activeRules, final SensorContext sensorContext) {
	this.javaResourceLocator = javaResourceLocator;

	for (final ActiveRule activeRule : activeRules.findAll()) {
		if (activeRule.ruleKey().repository().equals(XanitizerRulesDefinition.REPOSITORY_KEY)) {
			final String ruleAsString = activeRule.ruleKey().rule();
			activeXanRuleNames.add(ruleAsString);
		}
	}
	if (activeXanRuleNames.isEmpty()) {
		/*
		 * If no rule is active, we do not need to read the report file
		 */
		this.reportFile = null;
	} else {
		this.reportFile = SensorUtil.geReportFile(sensorContext);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:28,代码来源:XanitizerSensor.java

示例7: should_execute_and_save_issues_on_UTF8_with_BOM_file

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_with_BOM_file() {
  inputFile("my-feature-bom.feature", Charsets.UTF_8);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .build();
  checkFactory = new CheckFactory(activeRules);

  createGherkinSquidSensor().execute(context);

  assertThat(context.allIssues()).hasSize(3);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例8: should_execute_and_save_issues_on_UTF8_file

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_file() {
  inputFile("my-feature.feature", Charsets.UTF_8);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .build();
  checkFactory = new CheckFactory(activeRules);

  createGherkinSquidSensor().execute(context);

  assertThat(context.allIssues()).hasSize(3);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例9: should_execute_and_save_issues_on_UTF8_with_BOM_file_french

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_with_BOM_file_french() {
  inputFile("my-feature-bom-fr.feature", Charsets.UTF_8);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .build();
  checkFactory = new CheckFactory(activeRules);

  createGherkinSquidSensor().execute(context);

  assertThat(context.allIssues()).hasSize(3);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例10: should_execute_and_save_issues_on_UTF8_file_french

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_UTF8_file_french() {
  inputFile("my-feature-fr.feature", Charsets.UTF_8);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .build();
  checkFactory = new CheckFactory(activeRules);

  createGherkinSquidSensor().execute(context);

  assertThat(context.allIssues()).hasSize(3);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:17,代码来源:GherkinSquidSensorTest.java

示例11: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  String relativePath = "parsing-error.feature";
  inputFile(relativePath, Charsets.UTF_8);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createGherkinSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:20,代码来源:GherkinSquidSensorTest.java

示例12: should_execute_and_save_issues_on_ISO_8859_1_file

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_execute_and_save_issues_on_ISO_8859_1_file() {
  inputFile("myProperties.properties", Charsets.ISO_8859_1);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, CommentConventionCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, MissingNewlineAtEndOfFileCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, LineLengthCheck.class.getAnnotation(Rule.class).key()))
    .activate()
    .build();
  checkFactory = new CheckFactory(activeRules);

  createJavaPropertiesSquidSensor().execute(context);

  assertThat(context.allIssues()).hasSize(4);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:19,代码来源:JavaPropertiesSquidSensorTest.java

示例13: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  String relativePath = "parsingError.properties";
  inputFile(relativePath, Charsets.ISO_8859_1);

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createJavaPropertiesSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(2);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:20,代码来源:JavaPropertiesSquidSensorTest.java

示例14: should_raise_an_issue_because_the_parsing_error_rule_is_activated

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
  inputFile("parsingError.json");

  ActiveRules activeRules = (new ActiveRulesBuilder())
    .create(RuleKey.of(CheckList.REPOSITORY_KEY, "S2260"))
    .activate()
    .build();

  checkFactory = new CheckFactory(activeRules);

  context.setActiveRules(activeRules);
  createJSONSquidSensor().execute(context);
  Collection<Issue> issues = context.allIssues();
  assertThat(issues).hasSize(1);
  Issue issue = issues.iterator().next();
  assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:19,代码来源:JSONSquidSensorTest.java

示例15: setUp

import org.sonar.api.batch.rule.ActiveRules; //导入依赖的package包/类
@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);
}
 
开发者ID:SonarSource,项目名称:sonar-web,代码行数:20,代码来源:WebSensorTest.java


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