| Tim Windelschmidt | 67f45f8 | 2025-07-29 21:45:00 +0200 | [diff] [blame] | 1 | // Copyright The Monogon Project Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package main |
| 5 | |
| 6 | import ( |
| 7 | "flag" |
| 8 | "fmt" |
| 9 | "log" |
| 10 | "maps" |
| 11 | "os" |
| 12 | "slices" |
| 13 | "sort" |
| 14 | |
| 15 | "source.monogon.dev/build/analysis/staticcheck" |
| 16 | ) |
| 17 | |
| 18 | func main() { |
| 19 | out := flag.String("out", "", "The output file to write the list to") |
| 20 | flag.Parse() |
| 21 | |
| 22 | if *out == "" { |
| 23 | log.Fatal("-out argument is required") |
| 24 | } |
| 25 | |
| 26 | outFile, err := os.OpenFile(*out, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0655) |
| 27 | if err != nil { |
| 28 | log.Fatalf("failed opening file: %v", err) |
| 29 | } |
| 30 | defer outFile.Close() |
| 31 | |
| 32 | const fileHeader = "# Generated by //build/analysis/staticcheck/generate_analyzers\n# Do not modify!\n\nANALYZER_NAMES = [\n" |
| 33 | fmt.Fprint(outFile, fileHeader) |
| 34 | |
| 35 | analyzerNames := slices.Collect(maps.Keys(staticcheck.Analyzers)) |
| 36 | sort.Strings(analyzerNames) |
| 37 | |
| 38 | for _, name := range analyzerNames { |
| 39 | fmt.Fprintf(outFile, " %q,\n", name) |
| 40 | } |
| 41 | |
| 42 | const fileFooter = "]\n" |
| 43 | fmt.Fprint(outFile, fileFooter) |
| 44 | } |