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.
11311 public init(covered: Int, total: Int) {
12311 // Whole numbers, so a file exactly on a boundary never lands below it.
13311 if covered * 100 >= total * 90 {
14232 self = .high
15232 } else if covered * 100 >= total * 75 {
167 self = .medium
1772 } else {
1872 self = .low
1972 }
20311 }
21}