use of org.sonarqube.ws.Rules.Rule in project sonarqube by SonarSource.
the class DefaultActiveRulesLoader method readPage.
private static List<LoadedActiveRule> readPage(SearchResponse response) {
List<LoadedActiveRule> loadedRules = new LinkedList<>();
List<Rule> rulesList = response.getRulesList();
Map<String, ActiveList> actives = response.getActives().getActives();
for (Rule r : rulesList) {
ActiveList activeList = actives.get(r.getKey());
Active active = activeList.getActiveList(0);
LoadedActiveRule loadedRule = new LoadedActiveRule();
loadedRule.setRuleKey(RuleKey.parse(r.getKey()));
loadedRule.setName(r.getName());
loadedRule.setSeverity(active.getSeverity());
loadedRule.setCreatedAt(dateToLong(parseDateTime(active.getCreatedAt())));
loadedRule.setLanguage(r.getLang());
loadedRule.setInternalKey(r.getInternalKey());
if (r.hasTemplateKey()) {
RuleKey templateRuleKey = RuleKey.parse(r.getTemplateKey());
loadedRule.setTemplateRuleKey(templateRuleKey.rule());
}
Map<String, String> params = new HashMap<>();
for (Rules.Rule.Param param : r.getParams().getParamsList()) {
params.put(param.getKey(), param.getDefaultValue());
}
// overrides defaultValue if the key is the same
for (Param param : active.getParamsList()) {
params.put(param.getKey(), param.getValue());
}
loadedRule.setParams(params);
loadedRules.add(loadedRule);
}
return loadedRules;
}
Aggregations