@Test public void test_toCheckPriority() { assertThat(RulePriority.fromCheckPriority(Priority.BLOCKER)).isEqualTo(RulePriority.BLOCKER); assertThat(RulePriority.fromCheckPriority(Priority.CRITICAL)).isEqualTo(RulePriority.CRITICAL); assertThat(RulePriority.fromCheckPriority(Priority.MAJOR)).isEqualTo(RulePriority.MAJOR); assertThat(RulePriority.fromCheckPriority(Priority.MINOR)).isEqualTo(RulePriority.MINOR); assertThat(RulePriority.fromCheckPriority(Priority.INFO)).isEqualTo(RulePriority.INFO); } }
private void addRule(Class aClass, BelongsToProfile annotation, RulesProfile profile, String repositoryKey, ValidationMessages messages) { if ((annotation != null) && StringUtils.equals(annotation.title(), profile.getName())) { String ruleKey = RuleAnnotationUtils.getRuleKey(aClass); Rule rule = ruleFinder.findByKey(repositoryKey, ruleKey); if (rule == null) { messages.addWarningText("Rule not found: [repository=" + repositoryKey + ", key=" + ruleKey + "]"); } else { RulePriority priority = null; if (annotation.priority() != null) { priority = RulePriority.fromCheckPriority(annotation.priority()); } profile.activateRule(rule, priority); } } } }
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; }
private void addRule(Class aClass, BelongsToProfile annotation, RulesProfile profile, String repositoryKey, ValidationMessages messages) { if ((annotation != null) && StringUtils.equals(annotation.title(), profile.getName())) { String ruleKey = RuleAnnotationUtils.getRuleKey(aClass); Rule rule = ruleFinder.findByKey(repositoryKey, ruleKey); if (rule == null) { messages.addWarningText("Rule not found: [repository=" + repositoryKey + ", key=" + ruleKey + "]"); } else { RulePriority priority = null; if (annotation.priority() != null) { priority = RulePriority.fromCheckPriority(annotation.priority()); } profile.activateRule(rule, priority); } } } }
public static Rule createRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation, @Nullable RuleTags ruleTagsAnnotation) { 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()); setTags(rule, ruleTagsAnnotation); Field[] fields = clazz.getDeclaredFields(); if (fields != null) { for (Field field : fields) { addRuleProperty(rule, field); } } return rule; }
private void addRule(Class aClass, BelongsToProfile annotation, RulesProfile profile, String repositoryKey, ValidationMessages messages) { if ((annotation != null) && StringUtils.equals(annotation.title(), profile.getName())) { String ruleKey = RuleAnnotationUtils.getRuleKey(aClass); Rule rule = ruleFinder.findByKey(repositoryKey, ruleKey); if (rule == null) { messages.addWarningText("Rule not found: [repository=" + repositoryKey + ", key=" + ruleKey + "]"); } else { RulePriority priority = null; if (annotation.priority() != null) { priority = RulePriority.fromCheckPriority(annotation.priority()); } profile.activateRule(rule, priority); } } } }
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; }
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; }