@CheckForNull void loadActiveRule(BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile profile, String repositoryKey, Class<?> clazz) { BelongsToProfile belongsToProfile = clazz.getAnnotation(BelongsToProfile.class); if ((belongsToProfile != null) && StringUtils.equals(belongsToProfile.title(), profile.name())) { String ruleKey = RuleAnnotationUtils.getRuleKey(clazz); NewBuiltInActiveRule activeRule = profile.activateRule(repositoryKey, ruleKey); activeRule.overrideSeverity(belongsToProfile.priority().name()); } }
@Test public void defaultKeyShouldBeTheClassName() { String key = RuleAnnotationUtils.getRuleKey(AnnotatedCheck.class); assertThat(key, is(AnnotatedCheck.class.getName())); }
@Test public void shouldGetKey() { String key = RuleAnnotationUtils.getRuleKey(AnnotatedCheckWithParameters.class); assertThat(key, is("overridden_key")); } }
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 void addRule(Class<?> ruleClass, NewBuiltInQualityProfile profile, String repositoryKey) { if (AnnotationUtils.getAnnotation(ruleClass, ActivatedByDefault.class) != null) { String ruleKey = RuleAnnotationUtils.getRuleKey(ruleClass); profile.activateRule(repositoryKey, ruleKey); } }
@CheckForNull void loadActiveRule(BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile profile, String repositoryKey, Class<?> clazz) { BelongsToProfile belongsToProfile = clazz.getAnnotation(BelongsToProfile.class); if ((belongsToProfile != null) && StringUtils.equals(belongsToProfile.title(), profile.name())) { String ruleKey = RuleAnnotationUtils.getRuleKey(clazz); NewBuiltInActiveRule activeRule = profile.activateRule(repositoryKey, ruleKey); activeRule.overrideSeverity(belongsToProfile.priority().name()); } }
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); } } } }
@Override public final RulesProfile createProfile(ValidationMessages validation) { RulesProfile profile = RulesProfile.create(NAME, getLanguageKey()); for (Class ruleClass : CheckClasses.getCheckClasses()) { String ruleKey = RuleAnnotationUtils.getRuleKey(ruleClass); if (isActive(ruleClass)) { Rule rule = ruleFinder.findByKey(getRepositoryKey(), ruleKey); profile.activateRule(rule, null); } } return profile; }
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); } } } }