/** * Materialize the current active rule set for the profile * * @param activeRules * @param profileName * @return */ protected PmdRuleset createRuleset(List<ActiveRule> activeRules, String profileName) { PmdRuleset ruleset = new PmdRuleset(profileName); for (ActiveRule activeRule : activeRules) { if (activeRule.getRule().getPluginName().equals(PhpCodeSnifferRuleRepository.PHPCS_REPOSITORY_KEY)) { String configKey = activeRule.getRule().getKey(); PmdRule rule = new PmdRule(configKey, mapper.to(activeRule.getPriority())); List<PmdProperty> properties = null; List<ActiveRuleParam> activeRuleParams = activeRule.getActiveRuleParams(); if (activeRuleParams != null && !activeRuleParams.isEmpty()) { properties = new ArrayList<PmdProperty>(); for (ActiveRuleParam activeRuleParam : activeRuleParams) { properties.add(new PmdProperty(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue())); } } rule.setProperties(properties); ruleset.addRule(rule); processXPathRule(activeRule.getRuleKey(), rule); } } return ruleset; }
/** * Materialize the current active rule set for the profile * * @param activeRules * @param profileName * @return */ protected PmdRuleset createPmdRuleset(List<ActiveRule> activeRules, String profileName) { PmdRuleset ruleset = new PmdRuleset(profileName); for (ActiveRule activeRule : activeRules) { if (activeRule.getRule().getPluginName().equals(PhpmdRuleRepository.PHPMD_REPOSITORY_KEY)) { String configKey = activeRule.getRule().getConfigKey(); PmdRule rule = new PmdRule(configKey, mapper.to(activeRule.getPriority())); List<ActiveRuleParam> activeRuleParams = activeRule.getActiveRuleParams(); if (activeRuleParams != null && !activeRuleParams.isEmpty()) { List<PmdProperty> properties = new ArrayList<PmdProperty>(); for (ActiveRuleParam activeRuleParam : activeRuleParams) { properties.add(new PmdProperty(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue())); } rule.setProperties(properties); } ruleset.addRule(rule); processXPathRule(activeRule.getRuleKey(), rule); } } return ruleset; }
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; }