build: switch to golangci-lint

This commit is contained in:
Tomasz Zdybał 2019-09-12 11:10:51 +02:00
parent 57089a3c37
commit 593496a46e
No known key found for this signature in database
GPG key ID: F157D3BD6E2EED66
2 changed files with 10 additions and 11 deletions

3
.golangci.yml Normal file
View file

@ -0,0 +1,3 @@
linters-settings:
goconst:
min-occurrences: 6

View file

@ -324,7 +324,7 @@ func doTest(cmdline []string) {
build.MustRun(gotest) build.MustRun(gotest)
} }
// runs gometalinter on requested packages // runs golangci-lint on requested packages
func doLint(cmdline []string) { func doLint(cmdline []string) {
flag.CommandLine.Parse(cmdline) flag.CommandLine.Parse(cmdline)
@ -332,15 +332,12 @@ func doLint(cmdline []string) {
if len(flag.CommandLine.Args()) > 0 { if len(flag.CommandLine.Args()) > 0 {
packages = flag.CommandLine.Args() packages = flag.CommandLine.Args()
} }
// Get metalinter and install all supported linters // Get golangci-lint and install all supported linters
os.Setenv("GO111MODULE", "on") build.MustRun(goTool("get", "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0"))
build.MustRun(goTool("get", "gopkg.in/alecthomas/kingpin.v3-unstable@63abe20a23e29e80bbef8089bd3dee3ac25e5306"))
build.MustRun(goTool("get", "github.com/alecthomas/gometalinter@v3.0.0"))
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter"), "--install")
// Run fast linters batched together // Run fast linters batched together
configs := []string{ configs := []string{
"--vendor", "run",
"--tests", "--tests",
"--deadline=2m", "--deadline=2m",
"--disable-all", "--disable-all",
@ -350,14 +347,13 @@ func doLint(cmdline []string) {
"--enable=gofmt", "--enable=gofmt",
"--enable=misspell", "--enable=misspell",
"--enable=goconst", "--enable=goconst",
"--min-occurrences=6", // for goconst
} }
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter"), append(configs, packages...)...) build.MustRunCommand(filepath.Join(GOBIN, "golangci-lint"), append(configs, packages...)...)
// Run slow linters one by one // Run slow linters one by one
for _, linter := range []string{"unconvert", "gosimple"} { for _, linter := range []string{"unconvert", "gosimple"} {
configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter} configs = []string{"run", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter}
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter"), append(configs, packages...)...) build.MustRunCommand(filepath.Join(GOBIN, "golangci-lint"), append(configs, packages...)...)
} }
} }