Skip to content

Commit

Permalink
Revert changes to AddSpecdScore (#1362)
Browse files Browse the repository at this point in the history
Not all calculators handle ignoring score properly. That code is still
needed
  • Loading branch information
jaym authored Jul 9, 2024
1 parent 6fe69e6 commit 905c6f7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions policy/score_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ func AddSpecdScore(calculator ScoreCalculator, s *Score, found bool, impact *exp
return
}

// everything else is modify or activate

if impact.Scoring == explorer.ScoringSystem_IGNORE_SCORE {
calculator.Add(&Score{
// We override the type because:
// 1. If it is set to Result, its value will be added to the total
// calculation in most calculators despite its weight.
// 2. We don't want to set it to unscored, because technically we
// just ignore the score.
// Thus we set the score to unknown for the sake of the calculator,
// thus it knows it is handling a scored result, but also knows not
// to count it.
Type: ScoreType_Unknown,
Value: score.Value,
Weight: 0,
ScoreCompletion: score.ScoreCompletion,
DataCompletion: score.DataCompletion,
DataTotal: score.DataTotal,
}, nil)
return
}

if impact.Weight > 0 {
score.Weight = uint32(impact.Weight)
} else if score.Weight == 0 {
Expand Down

0 comments on commit 905c6f7

Please sign in to comment.