| 1 | | /// The colour band a coverage percentage falls in (docs/DESIGN.md, D4). |
| 2 | | public 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. |
| 11 | 302 | public init(covered: Int, total: Int) { |
| 12 | 302 | // Whole numbers, so a file exactly on a boundary never lands below it. |
| 13 | 302 | if covered * 100 >= total * 90 { |
| 14 | 216 | self = .high |
| 15 | 216 | } else if covered * 100 >= total * 75 { |
| 16 | 24 | self = .medium |
| 17 | 62 | } else { |
| 18 | 62 | self = .low |
| 19 | 62 | } |
| 20 | 302 | } |
| 21 | | } |