本文整理了Java中org.sonar.api.rules.Rule.getId
方法的一些代码示例,展示了Rule.getId
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.getId
方法的具体详情如下:
包路径:org.sonar.api.rules.Rule
类名称:Rule
方法名:getId
暂无
代码示例来源:origin: SonarSource/sonarqube
@CheckForNull
protected Integer getRuleId(Issue issue) {
Rule rule = ruleFinder.findByKey(issue.ruleKey());
return rule != null ? rule.getId() : null;
}
}
代码示例来源: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
@Test
public void should_success_finder_wrap() {
// has Id
assertThat(underTest.findById(rule1.getId()).getId()).isEqualTo(rule1.getId());
// should_find_by_id
assertThat(underTest.findById(rule3.getId()).getConfigKey()).isEqualTo("Checker/Treewalker/AnnotationUseStyleCheck");
// should_not_find_disabled_rule_by_id
assertThat(underTest.findById(rule2.getId())).isNull();
// should_find_by_key
Rule rule = underTest.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck");
assertThat(rule).isNotNull();
assertThat(rule.getKey()).isEqualTo(("com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck"));
assertThat(rule.isEnabled()).isTrue();
// find_should_return_null_if_no_results
assertThat(underTest.findByKey("checkstyle", "unknown")).isNull();
assertThat(underTest.find(RuleQuery.create().withRepositoryKey("checkstyle").withConfigKey("unknown"))).isNull();
// find_repository_rules
assertThat(underTest.findAll(RuleQuery.create().withRepositoryKey("checkstyle"))).hasSize(2);
// find_all_enabled
assertThat(underTest.findAll(RuleQuery.create())).extracting("id").containsOnly(rule1.getId(), rule3.getId(), rule4.getId());
assertThat(underTest.findAll(RuleQuery.create())).hasSize(3);
// do_not_find_disabled_rules
assertThat(underTest.findByKey("checkstyle", "DisabledCheck")).isNull();
// do_not_find_unknown_rules
assertThat(underTest.findAll(RuleQuery.create().withRepositoryKey("unknown_repository"))).isEmpty();
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
@Override
protected IssueDto doInsert(DbSession session, long now, DefaultIssue issue) {
ComponentDto component = component(session, issue);
ComponentDto project = project(session, issue);
int ruleId = rule(issue).getId();
IssueDto dto = IssueDto.toDtoForServerInsert(issue, component, project, ruleId, now);
getDbClient().issueDao().insert(session, dto);
return dto;
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-core-plugin
Rule rule = ruleFinder.findByKey(((RuleMeasure) measure).ruleKey());
if (rule != null) {
ruleId = rule.getId();
代码示例来源:origin: org.codehaus.sonar/sonar-batch
throw new IllegalStateException("Can not save a measure with unknown rule " + ruleMeasure);
model.setRuleId(ruleWithId.getId());
内容来源于网络,如有侵权,请联系作者删除!