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


Java RuleTemplate类代码示例

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


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

示例1: newRule

import org.sonar.squidbridge.annotations.RuleTemplate; //导入依赖的package包/类
@VisibleForTesting
protected void newRule(Class<?> ruleClass, NewRepository repository) {

  org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(ruleClass, org.sonar.check.Rule.class);
  if (ruleAnnotation == null) {
    throw new IllegalArgumentException("No Rule annotation was found on " + ruleClass);
  }
  String ruleKey = ruleAnnotation.key();
  if (StringUtils.isEmpty(ruleKey)) {
    throw new IllegalArgumentException("No key is defined in Rule annotation of " + ruleClass);
  }
  NewRule rule = repository.rule(ruleKey);
  if (rule == null) {
    throw new IllegalStateException("No rule was created for " + ruleClass + " in " + repository.key());
  }
  ruleMetadata(ruleClass, rule);

  rule.setTemplate(AnnotationUtils.getAnnotation(ruleClass, RuleTemplate.class) != null);
  if (ruleAnnotation.cardinality() == Cardinality.MULTIPLE) {
    throw new IllegalArgumentException("Cardinality is not supported, use the RuleTemplate annotation instead for " + ruleClass);
  }
}
 
开发者ID:SonarSource,项目名称:sonar-custom-rules-examples,代码行数:23,代码来源:MyJavaRulesDefinition.java


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