Skip to content

Commit

Permalink
divide by 0 (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon authored Jul 26, 2021
1 parent 4d7fb5d commit 8128f9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions checker/check_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ type CheckResult struct {

// CreateProportionalScore() creates a proportional score.
func CreateProportionalScore(b, t int) int {
if t == 0 {
return 0
}

return int(math.Min(float64(MaxResultScore*b/t), float64(MaxResultScore)))
}

Expand Down
3 changes: 2 additions & 1 deletion checks/pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ func PullRequests(c *checker.CheckRequest) checker.CheckResult {
totalWithPrs++
c.Dlogger.Debug("commit with PR: %s", commit.GetSHA())
} else {
c.Dlogger.Debug("!! found commit without PR: %s, committer: %s", commit.GetSHA(), commit.GetCommitter().GetLogin())
c.Dlogger.Debug("found commit without PR: %s, committer: %s", commit.GetSHA(), commit.GetCommitter().GetLogin())
}
}

reason := fmt.Sprintf("%d ouf of %d commits have a PR", totalWithPrs, total)
return checker.CreateProportionalScoreResult(CheckPullRequests, reason, totalWithPrs, total)
}

0 comments on commit 8128f9f

Please sign in to comment.