org.sonar.api.rules.Rule.setTags()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中org.sonar.api.rules.Rule.setTags方法的一些代码示例,展示了Rule.setTags的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.setTags方法的具体详情如下:
包路径:org.sonar.api.rules.Rule
类名称:Rule
方法名:setTags

Rule.setTags介绍

[英]For definition of rule only
[中]仅适用于规则的定义

代码示例

代码示例来源:origin: SonarSource/sonarqube

throw new SonarException("Node <key> is missing in <rule>");
rule.setTags(tags.toArray(new String[tags.size()]));

代码示例来源:origin: SonarSource/sonarqube

@Test
public void testTags() {
 Rule rule = Rule.create();
 assertThat(rule.getTags()).isEmpty();
 assertThat(rule.getSystemTags()).isEmpty();
 rule.setTags(new String[] {"tag1", "tag2"});
 assertThat(rule.getTags()).containsOnly("tag1", "tag2");
 assertThat(rule.getSystemTags()).isEmpty();
}

代码示例来源:origin: SonarSource/sonarqube

@Override
 public List<Rule> createRules() {
  Rule rule = Rule.create("checkstyle", "ConstantName", "Constant Name");
  rule.setDescription("Checks that constant names conform to the specified format");
  rule.setConfigKey("Checker/TreeWalker/ConstantName");
  rule.setSeverity(RulePriority.BLOCKER);
  rule.setStatus(Rule.STATUS_BETA);
  rule.setTags(new String[] {"style", "clumsy"});
  rule.createParameter("format").setDescription("Regular expression").setDefaultValue("A-Z").setType("REGULAR_EXPRESSION");
  return Arrays.asList(rule);
 }
}

代码示例来源:origin: SonarSource/sonarqube

private static Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) {
 String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName());
 String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null);
 String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null);
 Rule rule = Rule.create(repositoryKey, ruleKey, ruleName);
 rule.setDescription(description);
 rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority()));
 rule.setCardinality(ruleAnnotation.cardinality());
 rule.setStatus(ruleAnnotation.status());
 rule.setTags(ruleAnnotation.tags());
 List<Field> fields = FieldUtils2.getFields(clazz, true);
 for (Field field : fields) {
  addRuleProperty(rule, field);
 }
 return rule;
}

代码示例来源:origin: SonarSource/sonarqube

.setStatus(rule.getStatus().name())
 .setSystemTags(rule.getSystemTags().toArray(new String[rule.getSystemTags().size()]))
 .setTags(rule.getTags().toArray(new String[rule.getTags().size()]))
 .setId(rule.getId());
if (description != null && descriptionFormat != null) {

代码示例来源:origin: SonarSource/sonarqube

.setStatus(ruleDefinition.getStatus().name())
 .setSystemTags(ruleDefinition.getSystemTags().toArray(new String[ruleDefinition.getSystemTags().size()]))
 .setTags(new String[0])
 .setId(ruleDefinition.getId());
if (description != null && descriptionFormat != null) {

代码示例来源:origin: org.codehaus.sonar/sonar-deprecated

throw new SonarException("Node <key> is missing in <rule>");
rule.setTags(tags.toArray(new String[tags.size()]));

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

private static Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) {
 String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName());
 String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null);
 String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null);
 Rule rule = Rule.create(repositoryKey, ruleKey, ruleName);
 rule.setDescription(description);
 rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority()));
 rule.setCardinality(ruleAnnotation.cardinality());
 rule.setStatus(ruleAnnotation.status());
 rule.setTags(ruleAnnotation.tags());
 List<Field> fields = FieldUtils2.getFields(clazz, true);
 for (Field field : fields) {
  addRuleProperty(rule, field);
 }
 return rule;
}

代码示例来源:origin: org.codehaus.sonar/sonar-deprecated

private Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) {
 String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName());
 String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null);
 String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null);
 Rule rule = Rule.create(repositoryKey, ruleKey, ruleName);
 rule.setDescription(description);
 rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority()));
 rule.setCardinality(ruleAnnotation.cardinality());
 rule.setStatus(ruleAnnotation.status());
 rule.setTags(ruleAnnotation.tags());
 List<Field> fields = FieldUtils2.getFields(clazz, true);
 for (Field field : fields) {
  addRuleProperty(rule, field);
 }
 return rule;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

.setStatus(rule.getStatus().name())
 .setSystemTags(rule.getSystemTags().toArray(new String[rule.getSystemTags().size()]))
 .setTags(rule.getTags().toArray(new String[rule.getTags().size()]))
 .setId(rule.getId());
if (description != null && descriptionFormat != null) {

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

.setStatus(ruleDefinition.getStatus().name())
 .setSystemTags(ruleDefinition.getSystemTags().toArray(new String[ruleDefinition.getSystemTags().size()]))
 .setTags(new String[0])
 .setId(ruleDefinition.getId());
if (description != null && descriptionFormat != null) {

代码示例来源:origin: fabriciocolombo/sonar-delphi

private static Rule createRepositoryRule(DelphiRule fRule) {
 RulePriority priority = severityFromLevel(fRule.getPriority());
 Rule rule = Rule.create(DelphiPmdConstants.REPOSITORY_KEY, fRule.getName(), fRule.getMessage()).setSeverity(
  priority);
 rule.setDescription(fRule.getDescription());
 rule.setTags(fRule.getTags());
 rule.setConfigKey(fRule.getClazz());
 List<RuleParam> ruleParams = new ArrayList<RuleParam>();
 if (fRule.getProperties() != null) {
  for (Property property : fRule.getProperties()) {
   RuleParam param = rule.createParameter()
    .setKey(property.getName())
    .setDescription(property.getName())
    .setType("s");
   if (NumberUtils.isNumber(property.getValue())) {
    param.setType("i");
   }
   param.setDefaultValue(property.getValue());
   ruleParams.add(param);
  }
 }
 rule.setParams(ruleParams);
 return rule;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

throw new SonarException("Node <key> is missing in <rule>");
rule.setTags(tags.toArray(new String[tags.size()]));

相关文章