use of org.sonar.server.rule.HotspotRuleDescription in project sonarqube by SonarSource.
the class ShowAction method formatRule.
private static void formatRule(ShowWsResponse.Builder responseBuilder, RuleDefinitionDto ruleDefinitionDto) {
SecurityStandards securityStandards = SecurityStandards.fromSecurityStandards(ruleDefinitionDto.getSecurityStandards());
SecurityStandards.SQCategory sqCategory = securityStandards.getSqCategory();
Hotspots.Rule.Builder ruleBuilder = Hotspots.Rule.newBuilder().setKey(ruleDefinitionDto.getKey().toString()).setName(nullToEmpty(ruleDefinitionDto.getName())).setSecurityCategory(sqCategory.getKey()).setVulnerabilityProbability(sqCategory.getVulnerability().name());
HotspotRuleDescription hotspotRuleDescription = HotspotRuleDescription.from(ruleDefinitionDto);
hotspotRuleDescription.getVulnerable().ifPresent(ruleBuilder::setVulnerabilityDescription);
hotspotRuleDescription.getRisk().ifPresent(ruleBuilder::setRiskDescription);
hotspotRuleDescription.getFixIt().ifPresent(ruleBuilder::setFixRecommendations);
responseBuilder.setRule(ruleBuilder.build());
}
Aggregations