Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use 100 for the default value of impact #1514

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions policy/score_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ func (c *bandedScoreCalculator) Add(score *Score, impact *explorer.Impact) {
c.scoreCompletion += score.ScoreCompletion

if score.ScoreCompletion != 0 && score.Weight != 0 {
category := score.Value
if impact != nil {
category := uint32(0)
if impact != nil && impact.Value != nil {
category = 100 - uint32(impact.Value.Value)
}

Expand Down
17 changes: 17 additions & 0 deletions policy/score_calculator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@ func TestBandedScores(t *testing.T) {
},
out: &Score{Value: 9, ScoreCompletion: 100, DataCompletion: 66, Weight: 20, Type: ScoreType_Result},
},
{
in: []*Score{
// 10 critical checks (9ok, 1not)
{Value: 0, ScoreCompletion: 100, DataCompletion: 80, DataTotal: 5, Weight: 1, Type: ScoreType_Result},
{Value: 100, ScoreCompletion: 100, DataCompletion: 100, DataTotal: 1, Weight: 9, Type: ScoreType_Result},
// 10 high checks (ok)
{Value: 100, ScoreCompletion: 100, DataCompletion: 33, DataTotal: 3, Weight: 10, Type: ScoreType_Result},
},
impacts: []*explorer.Impact{
// 10 critical checks
{Value: &explorer.ImpactValue{Value: 100}},
{Value: nil},
// 10 high checks
{Value: &explorer.ImpactValue{Value: 80}},
},
out: &Score{Value: 45, ScoreCompletion: 100, DataCompletion: 66, Weight: 20, Type: ScoreType_Result},
Comment on lines +290 to +294
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part of the test.

The previous test (L273) uses impact 100. The PR description states that we use 100 for impact, when it is nil.
Shouldn't the scores be the same in the two tests? L277 vs. L294

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i copied the test on 243. This one is slightly different than the one that is directly before. score values 0, 100, 0 vs 0, 100, 100

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Thanks.

},
})
}

Expand Down
Loading