vikunja-api/vendor/honnef.co/go/tools/cmd/staticcheck/staticcheck.go

45 lines
1.1 KiB
Go
Raw Normal View History

2019-02-18 20:32:41 +01:00
// staticcheck analyses Go code and makes it better.
2018-12-31 02:18:41 +01:00
package main // import "honnef.co/go/tools/cmd/staticcheck"
import (
"log"
2018-12-31 02:18:41 +01:00
"os"
"golang.org/x/tools/go/analysis"
2019-02-18 20:32:41 +01:00
"honnef.co/go/tools/lint"
2018-12-31 02:18:41 +01:00
"honnef.co/go/tools/lint/lintutil"
2019-02-18 20:32:41 +01:00
"honnef.co/go/tools/simple"
2018-12-31 02:18:41 +01:00
"honnef.co/go/tools/staticcheck"
2019-02-18 20:32:41 +01:00
"honnef.co/go/tools/stylecheck"
"honnef.co/go/tools/unused"
2018-12-31 02:18:41 +01:00
)
func main() {
fs := lintutil.FlagSet("staticcheck")
wholeProgram := fs.Bool("unused.whole-program", false, "Run unused in whole program mode")
debug := fs.String("debug.unused-graph", "", "Write unused's object graph to `file`")
2018-12-31 02:18:41 +01:00
fs.Parse(os.Args[1:])
2019-02-18 20:32:41 +01:00
var cs []*analysis.Analyzer
for _, v := range simple.Analyzers {
cs = append(cs, v)
}
for _, v := range staticcheck.Analyzers {
cs = append(cs, v)
}
for _, v := range stylecheck.Analyzers {
cs = append(cs, v)
2018-12-31 02:18:41 +01:00
}
2019-02-18 20:32:41 +01:00
u := unused.NewChecker(*wholeProgram)
if *debug != "" {
f, err := os.OpenFile(*debug, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
log.Fatal(err)
}
u.Debug = f
}
cums := []lint.CumulativeChecker{u}
lintutil.ProcessFlagSet(cs, cums, fs)
2018-12-31 02:18:41 +01:00
}