diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000..f218300651 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +linters-settings: + goconst: + min-occurrences: 6 diff --git a/build/ci.go b/build/ci.go index 23e4045f81..fb988e7b51 100644 --- a/build/ci.go +++ b/build/ci.go @@ -324,7 +324,7 @@ func doTest(cmdline []string) { build.MustRun(gotest) } -// runs gometalinter on requested packages +// runs golangci-lint on requested packages func doLint(cmdline []string) { flag.CommandLine.Parse(cmdline) @@ -332,15 +332,12 @@ func doLint(cmdline []string) { if len(flag.CommandLine.Args()) > 0 { packages = flag.CommandLine.Args() } - // Get metalinter and install all supported linters - os.Setenv("GO111MODULE", "on") - 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") + // Get golangci-lint and install all supported linters + build.MustRun(goTool("get", "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.18.0")) // Run fast linters batched together configs := []string{ - "--vendor", + "run", "--tests", "--deadline=2m", "--disable-all", @@ -350,14 +347,13 @@ func doLint(cmdline []string) { "--enable=gofmt", "--enable=misspell", "--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 for _, linter := range []string{"unconvert", "gosimple"} { - configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter} - build.MustRunCommand(filepath.Join(GOBIN, "gometalinter"), append(configs, packages...)...) + configs = []string{"run", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter} + build.MustRunCommand(filepath.Join(GOBIN, "golangci-lint"), append(configs, packages...)...) } }