From 668ac590fb5e2529ee7550c0a81492384a3c7376 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 8 Jun 2022 13:36:29 -0500 Subject: SONAR-16472 Set 'security_hotspots_reviewed_status' and 'security_hotspots_to_review_status' to all components --- .../qualitymodel/SecurityReviewMeasuresVisitor.java | 5 ++--- .../qualitymodel/SecurityReviewMeasuresVisitorTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitor.java index 9e73be46329..1d8255bd176 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitor.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitor.java @@ -62,9 +62,6 @@ public class SecurityReviewMeasuresVisitor extends PathAwareVisitorAdapter path) { computeMeasure(project, path); - // The following measures are only computed on projects level as they are required to compute the others measures on applications - measureRepository.add(project, securityHotspotsReviewedStatusMetric, newMeasureBuilder().create(path.current().getHotspotsReviewed())); - measureRepository.add(project, securityHotspotsToReviewStatusMetric, newMeasureBuilder().create(path.current().getHotspotsToReview())); } @Override @@ -83,6 +80,8 @@ public class SecurityReviewMeasuresVisitor extends PathAwareVisitorAdapter issue.type().equals(SECURITY_HOTSPOT)) .forEach(issue -> path.current().processHotspot(issue)); + measureRepository.add(component, securityHotspotsReviewedStatusMetric, newMeasureBuilder().create(path.current().getHotspotsReviewed())); + measureRepository.add(component, securityHotspotsToReviewStatusMetric, newMeasureBuilder().create(path.current().getHotspotsToReview())); Optional percent = computePercent(path.current().getHotspotsToReview(), path.current().getHotspotsReviewed()); measureRepository.add(component, securityReviewRatingMetric, RatingMeasures.get(computeRating(percent.orElse(null)))); percent.ifPresent(p -> measureRepository.add(component, securityHotspotsReviewedMetric, newMeasureBuilder().create(p, securityHotspotsReviewedMetric.getDecimalScale()))); diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitorTest.java index 0e67efb2e25..a22e5109de9 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitymodel/SecurityReviewMeasuresVisitorTest.java @@ -273,10 +273,10 @@ public class SecurityReviewMeasuresVisitorTest { underTest.visit(ROOT_PROJECT); - verifyHotspotStatusMeasures(FILE_1_REF, null, null); - verifyHotspotStatusMeasures(FILE_2_REF, null, null); - verifyHotspotStatusMeasures(DIRECTORY_REF, null, null); - verifyHotspotStatusMeasures(ROOT_DIR_REF, null, null); + verifyHotspotStatusMeasures(FILE_1_REF, 1, 1); + verifyHotspotStatusMeasures(FILE_2_REF, 3, 2); + verifyHotspotStatusMeasures(DIRECTORY_REF, 4, 3); + verifyHotspotStatusMeasures(ROOT_DIR_REF, 4, 3); verifyHotspotStatusMeasures(PROJECT_REF, 4, 3); } -- cgit v1.2.3