| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
| 8 | const maxFileLines = 800 |
| 9 | |
| 10 | // Translation tables are data, not code: they grow one entry per UI string, so |
| 11 | // a ceiling there fires on every new label without ever pointing at something |
| 12 | // worth splitting. |
| 13 | var sizeExemptPrefixes = []string{ |
| 14 | "desktop/frontend/src/locales/", |
| 15 | } |
| 16 | |
| 17 | func sizeExempt(rel string) bool { |
| 18 | for _, prefix := range sizeExemptPrefixes { |
| 19 | if strings.HasPrefix(rel, prefix) { |
| 20 | return true |
| 21 | } |
| 22 | } |
| 23 | return false |
| 24 | } |
| 25 | |
| 26 | func checkSize(s *sourceFile) []Finding { |
| 27 | if s.lines <= maxFileLines || sizeExempt(s.rel) { |
| 28 | return nil |
| 29 | } |
| 30 | rule := ruleFileSize |
| 31 | if s.isTest() { |
| 32 | rule = ruleTestSize |
| 33 | } |
| 34 | return []Finding{{s.rel, 1, rule, |
| 35 | fmt.Sprintf("%d lines exceeds the %d-line ceiling", s.lines, maxFileLines), s.lines - maxFileLines}} |
| 36 | } |
| 37 |