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


Java RulesDefinition.Context方法代码示例

本文整理汇总了Java中org.sonar.api.server.rule.RulesDefinition.Context方法的典型用法代码示例。如果您正苦于以下问题:Java RulesDefinition.Context方法的具体用法?Java RulesDefinition.Context怎么用?Java RulesDefinition.Context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.server.rule.RulesDefinition的用法示例。


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

示例1: testDefineBasic

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void testDefineBasic() {
  Languages languages = new Languages(testLanguage("java"));
  CoverageRule rule = new CoverageRule(languages);
  RulesDefinition.Context context = new Context();

  assertTrue(context.repositories().isEmpty());
  rule.define(context);
  List<Repository> repos = context.repositories();
  assertEquals(1, repos.size());

  Repository repo = repos.get(0);
  assertEquals("Coverage evolution", repo.name());
  List<Rule> rules = repo.rules();
  assertEquals(2, rules.size());
}
 
开发者ID:AmadeusITGroup,项目名称:sonar-coverage-evolution,代码行数:17,代码来源:CoverageRuleTest.java

示例2: testExecute

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void testExecute() throws IOException {

	Context t = new RulesDefinition.Context();
	ScriptAnalyzerRulesDefinition def = new ScriptAnalyzerRulesDefinition();
	def.define(t);

	File baseFile = folder.newFile("test.ps1");

	FileUtils.copyURLToFile(getClass().getResource("/testFiles/test.ps1"), baseFile);

	DefaultFileSystem fs = new DefaultFileSystem(folder.getRoot());
	DefaultInputFile ti = new DefaultInputFile("test", "test.ps1");
	ti.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));

	fs.add(ti);

	SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
	ScriptAnalyzerSensor s = new ScriptAnalyzerSensor(fs, temp);
	s.execute(ctxTester);
	Assert.assertEquals(4, ctxTester.allIssues().size());

}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:24,代码来源:ScriptAnalyzerSensorTest.java

示例3: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomScssRulesDefinition rulesDefinition = new MyCustomScssRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("scss");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:22,代码来源:CustomScssRulesDefinitionTest.java

示例4: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomLessRulesDefinition rulesDefinition = new MyCustomLessRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("less");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:22,代码来源:CustomLessRulesDefinitionTest.java

示例5: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomCssRulesDefinition rulesDefinition = new MyCustomCssRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("css");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:22,代码来源:CustomCssRulesDefinitionTest.java

示例6: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  CssRulesDefinition rulesDefinition = new CssRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository("css");

  assertThat(repository.name()).isEqualTo("SonarQube");
  assertThat(repository.language()).isEqualTo("css");
  assertThat(repository.rules()).hasSize(88);
  assertThat(CheckList.getEmbeddedCssChecks()).hasSize(repository.rules().size() - 6);


  RulesDefinition.Rule todoRule = repository.rule(TodoTagCheck.class.getAnnotation(Rule.class).key());
  assertThat(todoRule).isNotNull();
  assertThat(todoRule.name()).isEqualTo(TodoTagCheck.class.getAnnotation(Rule.class).name());
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:18,代码来源:CssRulesDefinitionTest.java

示例7: testDefinition

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void testDefinition() {
    final RulesDefinition.Context context = new RulesDefinition.Context();
    new Rules().define(context);
    final RulesDefinition.Repository repository = context.repository(Rules.REPOSITORY);

    Assert.assertEquals("jDepend", repository.name());
    Assert.assertEquals("java", repository.language());

    Assert.assertEquals(7, repository.rules().size());

    Assert.assertNotNull(repository.rule(NumberOfClassesAndInterfacesRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(AfferentCouplingsRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(EfferentCouplingsRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(AbstractnessRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(InstabilityRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(DistanceFromMainSequenceRule.RULE_KEY.rule()));
    Assert.assertNotNull(repository.rule(PackageDependencyCyclesRule.RULE_KEY.rule()));
}
 
开发者ID:willemsrb,项目名称:sonar-jdepend-plugin,代码行数:20,代码来源:RulesTest.java

示例8: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCssCustomRulesDefinition rulesDefinition = new MyCssCustomRulesDefinition();

  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);

  RulesDefinition.Repository repository = context.repository("custom-css");

  assertThat(repository.name()).isEqualTo("My CSS Custom Repository");
  assertThat(repository.language()).isEqualTo("css");
  assertThat(repository.rules()).hasSize(2);

  RulesDefinition.Rule forbiddenPropertiesRule = repository.rule(ForbiddenPropertiesCheck.class.getAnnotation(Rule.class).key());
  assertThat(forbiddenPropertiesRule).isNotNull();
  assertThat(forbiddenPropertiesRule.name()).isEqualTo(ForbiddenPropertiesCheck.class.getAnnotation(Rule.class).name());
}
 
开发者ID:racodond,项目名称:sonar-css-custom-rules-plugin,代码行数:18,代码来源:MyCssCustomRulesDefinitionTest.java

示例9: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyLessCustomRulesDefinition rulesDefinition = new MyLessCustomRulesDefinition();

  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);

  RulesDefinition.Repository repository = context.repository("custom-less");

  assertThat(repository.name()).isEqualTo("My Less Custom Repository");
  assertThat(repository.language()).isEqualTo("less");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule interpolatedPropertiesRule = repository.rule(InterpolatedPropertiesCheck.class.getAnnotation(Rule.class).key());
  assertThat(interpolatedPropertiesRule).isNotNull();
  assertThat(interpolatedPropertiesRule.name()).isEqualTo(InterpolatedPropertiesCheck.class.getAnnotation(Rule.class).name());
}
 
开发者ID:racodond,项目名称:sonar-css-custom-rules-plugin,代码行数:18,代码来源:MyLessCustomRulesDefinitionTest.java

示例10: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
    PerlCriticRulesDefinition def = new PerlCriticRulesDefinition();
    RulesDefinition.Context context = new RulesDefinition.Context();
    def.define(context);
    RulesDefinition.Repository repository = context.repository(PerlCriticRulesDefinition.getRepositoryKey());

    assertThat(repository.name()).isEqualTo(PerlCriticRulesDefinition.getRepositoryName());
    assertThat(repository.language()).isEqualTo(PerlLanguage.KEY);

    List<Rule> rules = repository.rules();
    assertThat(rules).hasSize(272);

    for (Rule rule : rules) {
        assertThat(rule.debtRemediationFunction()).describedAs(rule.key()).isNotNull();
        assertThat(rule.debtRemediationFunction().type()).describedAs(rule.key()).isEqualTo(LINEAR);
    }
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:19,代码来源:PerlCriticRulesDefinitionTest.java

示例11: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyGherkinCustomRulesDefinition rulesDefinition = new MyGherkinCustomRulesDefinition();

  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);

  RulesDefinition.Repository repository = context.repository("custom-gherkin");

  assertThat(repository.name()).isEqualTo("My Gherkin Custom Repository");
  assertThat(repository.language()).isEqualTo("gherkin");
  assertThat(repository.rules()).hasSize(2);

  RulesDefinition.Rule forbiddenKeysRule = repository.rule(ForbiddenTagCheck.class.getAnnotation(Rule.class).key());
  assertThat(forbiddenKeysRule).isNotNull();
  assertThat(forbiddenKeysRule.name()).isEqualTo(ForbiddenTagCheck.class.getAnnotation(Rule.class).name());
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:18,代码来源:MyGherkinCustomRulesDefinitionTest.java

示例12: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomGherkinRulesDefinition rulesDefinition = new MyCustomGherkinRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("gherkin");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:22,代码来源:CustomGherkinRulesDefinitionTest.java

示例13: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomJavaPropertiesRulesDefinition rulesDefinition = new MyCustomJavaPropertiesRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("jproperties");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:22,代码来源:CustomJavaPropertiesRulesDefinitionTest.java

示例14: test

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void test() {
  MyCustomJSONRulesDefinition rulesDefinition = new MyCustomJSONRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);
  RulesDefinition.Repository repository = context.repository(REPOSITORY_KEY);

  assertThat(repository.name()).isEqualTo(REPOSITORY_NAME);
  assertThat(repository.language()).isEqualTo("json");
  assertThat(repository.rules()).hasSize(1);

  RulesDefinition.Rule customRule = repository.rule(RULE_KEY);
  assertThat(customRule).isNotNull();
  assertThat(customRule.key()).isEqualTo(RULE_KEY);
  assertThat(customRule.name()).isEqualTo(RULE_NAME);

  RulesDefinition.Param param = repository.rules().get(0).params().get(0);
  assertThat(param.key()).isEqualTo("customParam");
  assertThat(param.description()).isEqualTo("Custom parameter");
  assertThat(param.defaultValue()).isEqualTo("Default value");
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:22,代码来源:CustomJSONRulesDefinitionTest.java

示例15: testRulesDefinition

import org.sonar.api.server.rule.RulesDefinition; //导入方法依赖的package包/类
@Test
public void testRulesDefinition() {
  CSharpReSharperProvider.CSharpReSharperRulesDefinition rulesDefinition = new CSharpReSharperProvider.CSharpReSharperRulesDefinition();
  RulesDefinition.Context context = new RulesDefinition.Context();
  rulesDefinition.define(context);

  assertThat(context.repositories()).hasSize(1);
  RulesDefinition.Repository repo = context.repositories().get(0);

  assertThat(repo.language()).isEqualTo("cs");
  assertThat(repo.key()).isEqualTo("resharper-cs");

  List<RulesDefinition.Rule> rules = repo.rules();
  assertThat(rules.size()).isEqualTo(675);
  boolean atLeastOneSqale = false;
  for (RulesDefinition.Rule rule : rules) {
    assertThat(rule.key()).isNotNull();
    assertThat(rule.name()).isNotNull();
    assertThat(rule.htmlDescription()).isNotNull();
    if (!Strings.isNullOrEmpty(rule.debtSubCharacteristic())) {
      atLeastOneSqale = true;
    }
  }
  assertTrue(atLeastOneSqale);
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:26,代码来源:CSharpReSharperProviderTest.java


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