staticcheck (#313)
* CI: use staticcheck for linting This commit switches the linter for Go code from golint to staticcheck. Golint has been deprecated since last year and staticcheck is a recommended replacement. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * revendor Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * cmd,pkg: fix lint warnings Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
committed by
GitHub
parent
93f46e03ea
commit
50fbc2eec2
15
vendor/honnef.co/go/tools/cmd/staticcheck/README.md
vendored
Normal file
15
vendor/honnef.co/go/tools/cmd/staticcheck/README.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# staticcheck
|
||||
|
||||
_staticcheck_ offers extensive analysis of Go code, covering a myriad
|
||||
of categories. It will detect bugs, suggest code simplifications,
|
||||
point out dead code, and more.
|
||||
|
||||
## Installation
|
||||
|
||||
See [the main README](https://github.com/dominikh/go-tools#installation) for installation instructions.
|
||||
|
||||
## Documentation
|
||||
|
||||
Detailed documentation can be found on
|
||||
[staticcheck.io](https://staticcheck.io/docs/).
|
||||
|
45
vendor/honnef.co/go/tools/cmd/staticcheck/staticcheck.go
vendored
Normal file
45
vendor/honnef.co/go/tools/cmd/staticcheck/staticcheck.go
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// staticcheck analyses Go code and makes it better.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"honnef.co/go/tools/lintcmd"
|
||||
"honnef.co/go/tools/lintcmd/version"
|
||||
"honnef.co/go/tools/quickfix"
|
||||
"honnef.co/go/tools/simple"
|
||||
"honnef.co/go/tools/staticcheck"
|
||||
"honnef.co/go/tools/stylecheck"
|
||||
"honnef.co/go/tools/unused"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cmd := lintcmd.NewCommand("staticcheck")
|
||||
cmd.SetVersion(version.Version, version.MachineVersion)
|
||||
|
||||
fs := cmd.FlagSet()
|
||||
debug := fs.String("debug.unused-graph", "", "Write unused's object graph to `file`")
|
||||
qf := fs.Bool("debug.run-quickfix-analyzers", false, "Run quickfix analyzers")
|
||||
|
||||
cmd.ParseFlags(os.Args[1:])
|
||||
|
||||
cmd.AddAnalyzers(simple.Analyzers...)
|
||||
cmd.AddAnalyzers(staticcheck.Analyzers...)
|
||||
cmd.AddAnalyzers(stylecheck.Analyzers...)
|
||||
cmd.AddAnalyzers(unused.Analyzer)
|
||||
|
||||
if *qf {
|
||||
cmd.AddAnalyzers(quickfix.Analyzers...)
|
||||
}
|
||||
|
||||
if *debug != "" {
|
||||
f, err := os.OpenFile(*debug, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
unused.Debug = f
|
||||
}
|
||||
|
||||
cmd.Run()
|
||||
}
|
Reference in New Issue
Block a user