Skip to content

Commit

Permalink
Incorporate CODEOWNERS check as part of Code Review checks Level 4
Browse files Browse the repository at this point in the history
  • Loading branch information
raghavkaul authored and naveensrinivasan committed Jul 27, 2022
1 parent 8d8d854 commit 9b6bbca
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions checks/evaluation/branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
nonAdminContextLevel = 2 // Level 3.
nonAdminThoroughReviewLevel = 1 // Level 4.
adminThoroughReviewLevel = 1 // Level 5.
codeownerReviewLevel = 1 // Level 5.

)

Expand Down Expand Up @@ -224,14 +223,17 @@ func computeScore(scores []levelScore) (int, error) {
}

// Fourth, check the thorough non-admin reviews.
// Also check whether this repo requires codeowner review
maxThoroughReviewScore := maxScore.thoroughReview * len(scores)
maxCodeownerReviewScore := maxScore.codeownerReview * len(scores)
thoroughReviewScore := computeNonAdminThoroughReviewScore(scores)
score += noarmalizeScore(thoroughReviewScore, maxThoroughReviewScore, nonAdminThoroughReviewLevel)
codeownerReviewScore := computeCodeownerThoroughReviewScore(scores)
score += noarmalizeScore(thoroughReviewScore+codeownerReviewScore, maxThoroughReviewScore+maxCodeownerReviewScore, nonAdminThoroughReviewLevel)
if thoroughReviewScore != maxThoroughReviewScore {
return int(score), nil
}

// Fifth, check the thorough admin review config.
// Lastly, check the thorough admin review config.
// This one is controversial and has usability issues
// https://github.com/ossf/scorecard/issues/1027, so we may remove it.
maxAdminThoroughReviewScore := maxScore.adminThoroughReview * len(scores)
Expand All @@ -241,14 +243,6 @@ func computeScore(scores []levelScore) (int, error) {
return int(score), nil
}

// Lastly, check that a codeowner's approving review is required for merge
maxCodeownerReviewScore := maxScore.codeownerReview * len(scores)
codeownerReviewScore := computeCodeownerThoroughReviewScore(scores)
score += noarmalizeScore(codeownerReviewScore, maxCodeownerReviewScore, codeownerReviewLevel)
if codeownerReviewScore != maxCodeownerReviewScore {
return int(score), nil
}

return int(score), nil
}

Expand Down Expand Up @@ -457,5 +451,5 @@ func codeownersBranchProtection(branch *clients.BranchRef, dl checker.DetailLogg
}
}

return score, max // Don't deduct points - leave this as 'extra credit'
return score, max
}

0 comments on commit 9b6bbca

Please sign in to comment.