blob: bcf96ff19d56990da0c0a0a0aace9a99e5fcc849 [file] [log] [blame]
Tim Windelschmidt67f45f82025-07-29 21:45:00 +02001// Copyright The Monogon Project Authors.
2// SPDX-License-Identifier: Apache-2.0
3
4package main
5
6import (
7 "flag"
8 "fmt"
9 "log"
10 "maps"
11 "os"
12 "slices"
13 "sort"
14
15 "source.monogon.dev/build/analysis/staticcheck"
16)
17
18func 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}