diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-06-08 13:36:29 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-06-10 08:15:07 +0000 |
commit | 668ac590fb5e2529ee7550c0a81492384a3c7376 (patch) | |
tree | bc081ee4f9836bc740a4259c577de65db05c4f13 /server/sonar-ce-task-projectanalysis/src | |
parent | 144b731489f00e0eb2406036ddcf3fab3a5126aa (diff) | |
download | sonarqube-668ac590fb5e2529ee7550c0a81492384a3c7376.tar.gz sonarqube-668ac590fb5e2529ee7550c0a81492384a3c7376.zip |
SONAR-16472 Set 'security_hotspots_reviewed_status' and 'security_hotspots_to_review_status' to all components9.5.0.56709
Diffstat (limited to 'server/sonar-ce-task-projectanalysis/src')
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<Secur @Override public void visitProject(Component project, Path<SecurityReviewCounter> 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<Secur .filter(issue -> 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<Double> 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); } |