1/// The colour band a coverage percentage falls in (docs/DESIGN.md, D4).
2public enum CoverageTier: String, Sendable {
3 /// 90% and up.
4 case high
5 /// 75% and up.
6 case medium
7 case low
8
9 /// The tier of `covered` out of `total`; a file with no code counts as high,
10 /// since nothing in it went untested.
11401 public init(covered: Int, total: Int) {
12401 // Whole numbers, so a file exactly on a boundary never lands below it.
13401 if covered * 100 >= total * 90 {
14291 self = .high
15291 } else if covered * 100 >= total * 75 {
1631 self = .medium
1779 } else {
1879 self = .low
1979 }
20401 }
21}