private void activateProperties(ActiveRule activeRule, Map<String, String> properties) { for (Map.Entry<String, String> property : properties.entrySet()) { if (StringUtils.equals("severity", property.getKey())) { activeRule.setSeverity(CheckstyleSeverityUtils.fromSeverity(property.getValue())); } else if (!StringUtils.equals("id", property.getKey())) { activeRule.setParameter(property.getKey(), property.getValue()); } } }
private void activateProperties(ActiveRule activeRule, Map<String, String> properties) { for (Map.Entry<String, String> property : properties.entrySet()) { if (StringUtils.equals("severity", property.getKey())) { activeRule.setSeverity(CheckstyleSeverityUtils.fromSeverity(property.getValue())); } else if (!StringUtils.equals("id", property.getKey())) { activeRule.setParameter(property.getKey(), property.getValue()); } } } }
private static void activateProperties(ActiveRule activeRule, Map<String, String> properties) { for (Map.Entry<String, String> property : properties.entrySet()) { if (StringUtils.equals("severity", property.getKey())) { activeRule.setSeverity(CheckstyleSeverityUtils.fromSeverity(property.getValue())); } else if (!StringUtils.equals("id", property.getKey())) { activeRule.setParameter(property.getKey(), property.getValue()); } } }
private void createActiveRule(SMInputCursor rulesCursor, Map<String, ActiveRule> activeRules, String gendarmeCategory, RulesProfile profile, RulePriority rulePriority) throws XMLStreamException { String[] includedRules = StringUtils.split(rulesCursor.getAttrValue("include"), '|'); for (int i = 0; i < includedRules.length; i++) { String configKey = includedRules[i].trim() + "@" + gendarmeCategory; ActiveRule activeRule = activeRules.get(configKey); if (activeRule == null) { Rule rule = ruleFinder.find(ruleQuery.withConfigKey(configKey)); if (rule != null) { activeRule = profile.activateRule(rule, rulePriority); activeRules.put(configKey, activeRule); } } else if (activeRule.getSeverity().equals(RulePriority.MAJOR)) { // MAJOR is the default one: maybe another priority has been defined and we must set it activeRule.setSeverity(rulePriority); } } }
/** * @param optionalSeverity if null, then the default rule severity is used */ public ActiveRule activateRule(final Rule rule, @Nullable RulePriority optionalSeverity) { if (Iterables.any(activeRules, new Predicate<ActiveRule>() { @Override public boolean apply(ActiveRule input) { return input.getRule().equals(rule); } })) { throw MessageException.of(String.format( "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.", getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey())); } ActiveRule activeRule = new ActiveRule(); activeRule.setRule(rule); activeRule.setRulesProfile(this); activeRule.setSeverity(optionalSeverity == null ? rule.getSeverity() : optionalSeverity); activeRules.add(activeRule); return activeRule; }