@Override public Object clone() { return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue()); }
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 void appendRule(ActiveRule activeRule) throws IOException { String ruleKey = activeRule.getRuleKey(); // SONARGROOV-40 : key of rule having null parameters have been suffixed with ".fixed" if (ruleKey.endsWith(".fixed")) { ruleKey = ruleKey.substring(0, ruleKey.length() - ".fixed".length()); } writer.append("<rule class=\"").append(ruleKey); if (activeRule.getActiveRuleParams().isEmpty()) { writer.append(AUTO_CLOSING_TAG); } else { writer.append("\">\n"); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { String value = activeRuleParam.getValue(); String defaultValue = activeRuleParam.getRuleParam().getDefaultValue(); if (StringUtils.isNotBlank(value) && !value.equals(defaultValue)) { writer.append("<property name=\"") .append(activeRuleParam.getKey()) .append("\" value=\"") .append(StringEscapeUtils.escapeXml(value)) .append(AUTO_CLOSING_TAG); } } writer.append("</rule>\n"); } }
@Override public Object clone() { return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue()); }
@Override public Object clone() { return new ActiveRuleParam(getActiveRule(), getRuleParam(), getValue()); }
private static void addRuleProperties(ActiveRule activeRule, PmdRule pmdRule) { if ((activeRule.getActiveRuleParams() != null) && !activeRule.getActiveRuleParams().isEmpty()) { List<PmdProperty> properties = new ArrayList<>(); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { properties.add(new PmdProperty(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue())); } pmdRule.setProperties(properties); } }
private PmdRuleset createPmdRuleset(String repositoryKey, List<ActiveRule> activeRules, String profileName) { PmdRuleset ruleset = new PmdRuleset(profileName); for (ActiveRule activeRule : activeRules) { if (activeRule.getRule().getRepositoryKey().equals(repositoryKey)) { String configKey = activeRule.getRule().getConfigKey(); PmdRule rule = new PmdRule(configKey, PmdLevelUtils.toLevel(activeRule.getSeverity())); if ((activeRule.getActiveRuleParams() != null) && !activeRule.getActiveRuleParams().isEmpty()) { List<PmdProperty> properties = new ArrayList<PmdProperty>(); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { 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 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; }
private PmdRuleset createPmdRuleset(String repositoryKey, List<ActiveRule> activeRules, String profileName) { PmdRuleset ruleset = new PmdRuleset(profileName); for (ActiveRule activeRule : activeRules) { if (activeRule.getRule().getRepositoryKey().equals(repositoryKey)) { String configKey = activeRule.getRule().getConfigKey(); PmdRule rule = new PmdRule(configKey, PmdLevelUtils.toLevel(activeRule.getSeverity())); if ((activeRule.getActiveRuleParams() != null) && !activeRule.getActiveRuleParams().isEmpty()) { List<PmdProperty> properties = new ArrayList<>(); for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) { 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; }