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


Java Repository类代码示例

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


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

示例1: testDefineBasic

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的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: createActiveRules

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private ActiveRules createActiveRules() {
  ActiveRulesBuilder builder = new ActiveRulesBuilder();

  ListMultimap<String, RulesProfile> profilesByLanguage = profilesByLanguage(profileDefinitions);
  for (String language : profilesByLanguage.keySet()) {
    List<RulesProfile> defs = profilesByLanguage.get(language);
    registerProfilesForLanguage(builder, language, defs);
  }

  for (Repository repo : ruleDefsLoader.getContext().repositories()) {
    for (Rule rule : repo.rules()) {
      if (rule.activatedByDefault()) {
        NewActiveRule newAr = builder.create(RuleKey.of(repo.key(), rule.key()))
          .setLanguage(repo.language())
          .setName(rule.name())
          .setSeverity(rule.severity())
          .setInternalKey(rule.internalKey());
        for (Param param : rule.params()) {
          newAr.setParam(param.key(), param.defaultValue());
        }
        try {
          // TODO the Java plugin tries to add some rules twice... (for example squid:S2093)
          newAr.activate();
        } catch (IllegalStateException e) {
          if (!e.getMessage().contains("is already activated")) {
            throw new IllegalStateException(e);
          }
        }
      }
    }
  }

  return builder.build();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:35,代码来源:StandaloneActiveRulesProvider.java

示例3: test

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

  assertThat(repository.name()).isEqualTo("MyCompany Custom Repository");
  assertThat(repository.language()).isEqualTo("java");
  assertThat(repository.rules()).hasSize(RulesList.getChecks().size());

  assertRuleProperties(repository);
  assertParameterProperties(repository);
  assertAllRuleParametersHaveDescription(repository);
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:16,代码来源:MyJavaRulesDefinitionTest.java

示例4: assertParameterProperties

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertParameterProperties(Repository repository) {
  // TooManyLinesInFunctionCheck
  Param max = repository.rule("AvoidAnnotation").param("name");
  assertThat(max).isNotNull();
  assertThat(max.defaultValue()).isEqualTo("Inject");
  assertThat(max.description()).isEqualTo("Name of the annotation to avoid, without the prefix @, for instance 'Override'");
  assertThat(max.type()).isEqualTo(RuleParamType.STRING);
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:9,代码来源:MyJavaRulesDefinitionTest.java

示例5: assertRuleProperties

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertRuleProperties(Repository repository) {
  Rule rule = repository.rule("AvoidAnnotation");
  assertThat(rule).isNotNull();
  assertThat(rule.name()).isEqualTo("Title of AvoidAnnotation");
  assertThat(rule.debtRemediationFunction().type()).isEqualTo(Type.CONSTANT_ISSUE);
  assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL);
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:8,代码来源:MyJavaRulesDefinitionTest.java

示例6: assertAllRuleParametersHaveDescription

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertAllRuleParametersHaveDescription(Repository repository) {
  for (Rule rule : repository.rules()) {
    for (Param param : rule.params()) {
      assertThat(param.description()).as("description for " + param.key()).isNotEmpty();
    }
  }
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:8,代码来源:MyJavaRulesDefinitionTest.java

示例7: testRules

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
@Test
public void testRules() {
	final RulesDefinition rulesDefinition = new XanitizerRulesDefinition();
	final RulesDefinition.Context context = new RulesDefinition.Context();
	rulesDefinition.define(context);

	final Repository repository = context.repository(XanitizerRulesDefinition.REPOSITORY_KEY);
	assertNotNull(XanitizerRulesDefinition.REPOSITORY_KEY, repository);
	assertEquals(XanitizerRulesDefinition.LANGUAGE_KEY, repository.language());

	for (GeneratedProblemType problemType : GeneratedProblemType.values()) {
		assertNotNull(repository.rule(problemType.name()));
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:15,代码来源:PluginTest.java

示例8: test

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
@Test
public void test() {
  Repository repository = getRepositoryOfRules();

  assertEquals(repository.key(), "checkstyle");
  assertEquals(repository.name(), "Checkstyle");
  assertEquals(repository.language(), "java");
  assertEquals(repository.rules().isEmpty(), false);

  assertRuleProperties(repository);
  assertParameterProperties(repository);
  assertAllRuleParametersHaveDescription(repository);
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:14,代码来源:SonarRulesDefinitionTest.java

示例9: assertRuleProperties

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertRuleProperties(Repository repository) {
  Rule rule = repository.rule("es.startuphero.checkstyle.checks.modifier.MissingAbstractModifierCheck");
  assertNotNull(rule);
  assertEquals(rule.name(), "Missing Abstract Modifier Check");
  assertEquals(rule.htmlDescription(), "Missing Abstract Modifier Check");
  assertEquals(rule.internalKey(),
               "Checker/TreeWalker/"
               + "es.startuphero.checkstyle.checks.modifier.MissingAbstractModifierCheck");
  assertEquals(rule.type(), RuleType.CODE_SMELL);
  assertEquals(rule.severity(), Severity.MAJOR);
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:12,代码来源:SonarRulesDefinitionTest.java

示例10: assertParameterProperties

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertParameterProperties(Repository repository) {
  Param abstractTypeAnnotation =
      repository.rule("es.startuphero.checkstyle.checks.modifier.MissingAbstractModifierCheck")
                .param("abstractTypeAnnotation");
  assertNotNull(abstractTypeAnnotation);
  assertEquals(abstractTypeAnnotation.name(), "abstractTypeAnnotation");
  assertEquals(abstractTypeAnnotation.defaultValue(), "javax.persistence.MappedSuperclass");
  assertEquals(abstractTypeAnnotation.description(),
               "Abstract Type Annotation property with value of 'javax.persistence.MappedSuperclass'");
  assertEquals(abstractTypeAnnotation.type(), RuleParamType.STRING);
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:12,代码来源:SonarRulesDefinitionTest.java

示例11: assertAllRuleParametersHaveDescription

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private void assertAllRuleParametersHaveDescription(Repository repository) {
  for (Rule rule : repository.rules()) {
    for (Param param : rule.params()) {
      assertNotNull(param.description());
      assertNotNull(param.key());
    }
  }
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:9,代码来源:SonarRulesDefinitionTest.java

示例12: findByKey

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
@Override
public Rule findByKey(RuleKey key) {
  Repository repository = context.repository(key.repository());
  return repository != null ? toRule(repository.rule(key.rule())) : null;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:RuleFinderCompatibility.java

示例13: byRepository

import org.sonar.api.server.rule.RulesDefinition.Repository; //导入依赖的package包/类
private Collection<Rule> byRepository(RuleQuery query) {
  Repository repository = context.repository(query.getRepositoryKey());
  return repository != null ? repository.rules().stream().map(ruleTransformer).collect(Collectors.toList()) : Collections.<Rule>emptyList();
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:5,代码来源:RuleFinderCompatibility.java


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