/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRuleByConfigKey(String repositoryKey, String configKey) { for (ActiveRule activeRule : activeRules) { if (StringUtils.equals(activeRule.getRepositoryKey(), repositoryKey) && StringUtils.equals(activeRule.getConfigKey(), configKey) && activeRule.isEnabled()) { return activeRule; } } return null; }
private static ListMultimap<String, ActiveRule> arrangeByConfigKey(List<ActiveRule> activeRules) { ListMultimap<String, ActiveRule> result = ArrayListMultimap.create(); if (activeRules != null) { for (ActiveRule activeRule : activeRules) { result.put(activeRule.getConfigKey(), activeRule); } } return result; }
private static ListMultimap<String, ActiveRule> arrangeByConfigKey(List<ActiveRule> activeRules) { ListMultimap<String, ActiveRule> result = ArrayListMultimap.create(); if (activeRules != null) { for (ActiveRule activeRule : activeRules) { result.put(activeRule.getConfigKey(), activeRule); } } return result; }
private void appendRuleList(Writer writer, List<ActiveRule> rules) throws IOException { List<String> ruleNames = new ArrayList<String>(); for (ActiveRule activeRule : rules) { String key = activeRule.getConfigKey(); String ruleName = StringUtils.substringBefore(key, "@"); ruleNames.add(ruleName); } writer.append(StringUtils.join(ruleNames, " | ")); }
@Override public Object createCheck(ActiveRule activeRule) { Object object = checksByKey.get(activeRule.getConfigKey()); if (object != null) { return instantiate(activeRule, object); } return null; }
private static Map<String, List<ActiveRule>> arrangeByConfigKey(List<ActiveRule> activeRules) { final Map<String, List<ActiveRule>> result = new HashMap<>(); for (ActiveRule activeRule : activeRules) { final String key = activeRule.getConfigKey(); if (result.containsKey(key)) { final List<ActiveRule> rules = result.get(key); rules.add(activeRule); } else { final List<ActiveRule> rules = new ArrayList<>(); rules.add(activeRule); result.put(key, rules); } } return result; }
/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRuleByConfigKey(String repositoryKey, String configKey) { for (ActiveRule activeRule : activeRules) { if (StringUtils.equals(activeRule.getRepositoryKey(), repositoryKey) && StringUtils.equals(activeRule.getConfigKey(), configKey) && activeRule.isEnabled()) { return activeRule; } } return null; }
private List<String> enabledRuleConfigKeys() { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (ActiveRule activeRule : profile.getActiveRulesByRepository(fxCopConf.repositoryKey())) { if (!CUSTOM_RULE_KEY.equals(activeRule.getRuleKey())) { String effectiveConfigKey = activeRule.getConfigKey(); if (effectiveConfigKey == null) { effectiveConfigKey = activeRule.getParameter(CUSTOM_RULE_CHECK_ID_PARAMETER); } builder.add(effectiveConfigKey); } } return builder.build(); }
private void appendRuleParams(Writer writer, List<ActiveRule> assemblyRules) throws IOException { for (ActiveRule activeRule : assemblyRules) { List<ActiveRuleParam> params = activeRule.getActiveRuleParams(); for (ActiveRuleParam param : params) { String key = activeRule.getConfigKey(); String ruleName = StringUtils.substringBefore(key, "@"); String propertyName = param.getRuleParam().getKey(); String propertyValue = param.getValue(); writer.append(" <parameter rule=\""); writer.append(ruleName); writer.append("\" property=\""); writer.append(propertyName); writer.append("\" value=\""); writer.append(propertyValue); writer.append("\" />\n"); } } }
private String ruleKey(String ruleConfigKey) { for (ActiveRule activeRule : profile.getActiveRulesByRepository(fxCopConf.repositoryKey())) { if (ruleConfigKey.equals(activeRule.getConfigKey()) || ruleConfigKey.equals(activeRule.getParameter(CUSTOM_RULE_CHECK_ID_PARAMETER))) { return activeRule.getRuleKey(); } } throw new IllegalStateException( "Unable to find the rule key corresponding to the rule config key \"" + ruleConfigKey + "\" in repository \"" + fxCopConf.repositoryKey() + "\"."); }
String key = activeRule.getConfigKey(); String assembly = StringUtils.substringAfter(key, "@"); List<ActiveRule> assemblyRules = assemblyRulesMap.get(assembly);
/** * Note: disabled rules are excluded. */ @CheckForNull public ActiveRule getActiveRuleByConfigKey(String repositoryKey, String configKey) { for (ActiveRule activeRule : activeRules) { if (StringUtils.equals(activeRule.getRepositoryKey(), repositoryKey) && StringUtils.equals(activeRule.getConfigKey(), configKey) && activeRule.isEnabled()) { return activeRule; } } return null; }
public static FindBugsFilter buildFindbugsFilter(Iterable<ActiveRule> activeRules) { FindBugsFilter root = new FindBugsFilter(); for (ActiveRule activeRule : activeRules) { String repoKey = activeRule.getRepositoryKey(); if (repoKey.contains("findsecbugs") || repoKey.contains("findbugs") || repoKey.contains("fb-contrib")) { Match child = new Match(); child.setBug(new Bug(activeRule.getConfigKey())); root.addMatch(child); } } return root; }
private void appendModule(Writer writer, ActiveRule activeRule) throws IOException { String moduleName = StringUtils.substringAfterLast(activeRule.getConfigKey(), "/"); writer.append("<module name=\""); StringEscapeUtils.escapeXml(writer, moduleName); writer.append("\">"); if (activeRule.getRule().getParent() != null) { appendModuleProperty(writer, "id", activeRule.getRuleKey()); } appendModuleProperty(writer, "severity", CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity())); appendRuleParameters(writer, activeRule); writer.append("</module>"); }
private void appendModule(Writer writer, ActiveRule activeRule) throws IOException { String moduleName = StringUtils.substringAfterLast(activeRule.getConfigKey(), "/"); writer.append("<module name=\""); StringEscapeUtils.escapeXml(writer, moduleName); writer.append("\">"); if (activeRule.getRule().getTemplate() != null) { appendModuleProperty(writer, "id", activeRule.getRuleKey()); } appendModuleProperty(writer, "severity", CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity())); appendRuleParameters(writer, activeRule); writer.append("</module>"); }
private static void appendModule(Writer writer, ActiveRule activeRule) throws IOException { final String moduleName = StringUtils.substringAfterLast(activeRule.getConfigKey(), "/"); writer.append("<module name=\""); StringEscapeUtils.escapeXml(writer, moduleName); writer.append("\">"); if (activeRule.getRule().getTemplate() != null) { appendModuleProperty(writer, "id", activeRule.getRuleKey()); } appendModuleProperty(writer, "severity", CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity())); appendRuleParameters(writer, activeRule); writer.append(CLOSE_MODULE); }
static Ruleset buildRulesetFromActiveProfile(List<ActiveRule> activeRules) { Ruleset ruleset = new Ruleset(); for (ActiveRule activeRule : activeRules) { if (activeRule.getRule().getRepositoryKey().equals(DelphiPmdConstants.REPOSITORY_KEY)) { String key = activeRule.getRule().getKey(); String priority = severityToLevel(activeRule.getPriority()); List<Property> properties = new ArrayList<Property>(); DelphiRule delphiRule = new DelphiRule(activeRule.getConfigKey(), priority); delphiRule.setName(key); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { properties.add(new Property(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue())); } delphiRule.setProperties(properties); delphiRule.setMessage(activeRule.getRule().getName()); ruleset.addRule(delphiRule); } } return ruleset; }
private static void registerProfile(ActiveRulesBuilder builder, String language, Map.Entry<String, Collection<RulesProfile>> entry) { for (RulesProfile rp : entry.getValue()) { for (ActiveRule ar : rp.getActiveRules()) { Builder newAr = new NewActiveRule.Builder() .setRuleKey(RuleKey.of(ar.getRepositoryKey(), ar.getRuleKey())) .setLanguage(language) .setName(ar.getRule().getName()) .setSeverity(ar.getSeverity().name()) .setInternalKey(ar.getConfigKey()); for (ActiveRuleParam param : ar.getActiveRuleParams()) { newAr.setParam(param.getKey(), param.getValue()); } builder.addRule(newAr.build()); } } }