Skip to content

Commit 96a14d1

Browse files
move passed condition
Signed-off-by: YiscahLevySilas1 <[email protected]>
1 parent 9b848d3 commit 96a14d1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

score/score.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ func (su *ScoreUtil) GetFrameworkComplianceScore(framework *reportsummary.Framew
403403

404404
// GetControlComplianceScore returns the compliance score for a given control (as a percentage).
405405
func (su *ScoreUtil) GetControlComplianceScore(ctrl reportsummary.IControlSummary, _ /*frameworkName*/ string) float32 {
406+
// If a control has status passed it should always be considered as having 100% compliance score
407+
if ctrl.GetStatus().IsPassed() {
408+
return 100
409+
}
410+
406411
resourcesIDs := ctrl.ListResourcesIDs()
407412
passedResourceIDS := resourcesIDs.Passed()
408413
allResourcesIDSIter := resourcesIDs.All()
@@ -426,11 +431,5 @@ func (su *ScoreUtil) GetControlComplianceScore(ctrl reportsummary.IControlSummar
426431
if numOfAllResources > 0 {
427432
return (numOfPassedResources / numOfAllResources) * 100
428433
}
429-
430-
// in case the control didn't run on any resources:
431-
// If the control passed (irrelevant): score = 100 , else (skipped): score = 0
432-
if ctrl.GetStatus().IsPassed() {
433-
return 100
434-
}
435434
return 0
436435
}

0 commit comments

Comments
 (0)