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

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

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

Rule.getParams介绍

暂无

代码示例

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

@Test
public void overridden_rule() {
 List<Rule> rules = parseAnnotatedClass(OverridingRule.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo("overriding_foo");
 assertThat(rule.getName()).isEqualTo("Overriding Foo");
 assertThat(rule.getDescription()).isNull();
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
 assertThat(rule.getParams()).hasSize(2);
}

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

@Test
public void rule_with_property() {
 List<Rule> rules = parseAnnotatedClass(RuleWithProperty.class);
 assertThat(rules).hasSize(1);
 Rule rule = rules.get(0);
 assertThat(rule.getKey()).isEqualTo("foo");
 assertThat(rule.getName()).isEqualTo("bar");
 assertThat(rule.getDescription()).isEqualTo("Foo Bar");
 assertThat(rule.getSeverity()).isEqualTo(RulePriority.BLOCKER);
 assertThat(rule.getStatus()).isEqualTo(Rule.STATUS_READY);
 assertThat(rule.getParams()).hasSize(1);
 RuleParam prop = rule.getParam("property");
 assertThat(prop.getKey()).isEqualTo("property");
 assertThat(prop.getDescription()).isEqualTo("Ignore ?");
 assertThat(prop.getDefaultValue()).isEqualTo("false");
 assertThat(prop.getType()).isEqualTo(PropertyType.STRING.name());
}

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

private void verifyRule(Rule rule, RuleDefinitionDto ruleDefinition, RuleParamDto ruleParam) {
  assertThat(rule).isNotNull();

  assertThat(rule.getName()).isEqualTo(ruleDefinition.getName());
  assertThat(rule.getLanguage()).isEqualTo(ruleDefinition.getLanguage());
  assertThat(rule.getKey()).isEqualTo(ruleDefinition.getRuleKey());
  assertThat(rule.getConfigKey()).isEqualTo(ruleDefinition.getConfigKey());
  assertThat(rule.isTemplate()).isEqualTo(ruleDefinition.isTemplate());
  assertThat(rule.getCreatedAt().getTime()).isEqualTo(ruleDefinition.getCreatedAt());
  assertThat(rule.getUpdatedAt().getTime()).isEqualTo(ruleDefinition.getUpdatedAt());
  assertThat(rule.getRepositoryKey()).isEqualTo(ruleDefinition.getRepositoryKey());
  assertThat(rule.getSeverity().name()).isEqualTo(ruleDefinition.getSeverityString());
  assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().stream().toArray(String[]::new));
  assertThat(rule.getTags()).isEmpty();
  assertThat(rule.getId()).isEqualTo(ruleDefinition.getId());
  assertThat(rule.getDescription()).isEqualTo(ruleDefinition.getDescription());

  assertThat(rule.getParams()).hasSize(1);
  org.sonar.api.rules.RuleParam param = rule.getParams().iterator().next();
  assertThat(param.getRule()).isSameAs(rule);
  assertThat(param.getKey()).isEqualTo(ruleParam.getName());
  assertThat(param.getDescription()).isEqualTo(ruleParam.getDescription());
  assertThat(param.getType()).isEqualTo(ruleParam.getType());
  assertThat(param.getDefaultValue()).isEqualTo(ruleParam.getDefaultValue());
 }
}

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

newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
for (RuleParam param : rule.getParams()) {
 RulesDefinition.NewParam newParam = newRule.createParam(param.getKey());
 newParam.setDefaultValue(param.getDefaultValue());

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

static List<ActiveRuleParam>
 buildActiveRuleParams(DelphiRule delphiRule, Rule repositoryRule, ActiveRule activeRule) {
 List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
 if (delphiRule.getProperties() != null) {
  for (Property property : delphiRule.getProperties()) {
   if (repositoryRule.getParams() != null) {
    for (RuleParam ruleParam : repositoryRule.getParams()) {
     if (ruleParam.getKey().equals(property.getName())) {
      activeRuleParams.add(new ActiveRuleParam(activeRule, ruleParam, property.getValue()));
     }
    }
   }
  }
 }
 return activeRuleParams;
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/sonar-checkstyle-plugin

private void appendRuleParameters(Writer writer, ActiveRule activeRule) throws IOException {
 for (RuleParam ruleParam : activeRule.getRule().getParams()) {
  String value = activeRule.getParameter(ruleParam.getKey());
  if (StringUtils.isNotBlank(value)) {
   appendModuleProperty(writer, ruleParam.getKey(), value);
  }
 }
}

代码示例来源:origin: org.codehaus.sonar.plugins/sonar-checkstyle-plugin

private void appendRuleParameters(Writer writer, ActiveRule activeRule) throws IOException {
 for (RuleParam ruleParam : activeRule.getRule().getParams()) {
  String value = activeRule.getParameter(ruleParam.getKey());
  if (StringUtils.isNotBlank(value)) {
   appendModuleProperty(writer, ruleParam.getKey(), value);
  }
 }
}

代码示例来源:origin: checkstyle/sonar-checkstyle

private static void appendRuleParameters(Writer writer, ActiveRule activeRule)
    throws IOException {
  for (RuleParam ruleParam : activeRule.getRule().getParams()) {
    final String value = activeRule.getParameter(ruleParam.getKey());
    if (StringUtils.isNotBlank(value)) {
      appendModuleProperty(writer, ruleParam.getKey(), value);
    }
  }
}

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

@Override
public void define(Context context) {
 NewRepository repository = context
  .createRepository(DelphiPmdConstants.REPOSITORY_KEY, DelphiLanguage.KEY)
  .setName(DelphiPmdConstants.REPOSITORY_NAME);
 List<org.sonar.api.rules.Rule> rules = DelphiRulesUtils.getInitialReferential();
 // TODO Review
 // https://github.com/SonarCommunity/sonar-pmd/blob/master/src/main/java/org/sonar/plugins/pmd/PmdRulesDefinition.java
 for (org.sonar.api.rules.Rule rule : rules) {
  NewRule newRule = repository.createRule(rule.getKey())
   .setName(rule.getName())
   .setHtmlDescription(rule.getDescription())
   .setInternalKey(rule.getConfigKey())
   .setSeverity(rule.getSeverity().name());
  for (RuleParam param : rule.getParams()) {
   newRule.createParam(param.getKey())
    .setDefaultValue(param.getDefaultValue())
    .setType(RuleParamType.parse(param.getType()))
    .setDescription(param.getDescription());
  }
 }
 SqaleXmlLoader.load(repository, "/org/sonar/plugins/delphi/sqale/delphi-model.xml");
 repository.done();
}

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

newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
for (RuleParam param : rule.getParams()) {
 RulesDefinition.NewParam newParam = newRule.createParam(param.getKey());
 newParam.setDefaultValue(param.getDefaultValue());

相关文章