From 213e39a23fcd2ec11ad85b63d1cd4f3c40a494c1 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 17 Mar 2023 09:47:40 +0100 Subject: [PATCH 1/5] bump gocritic --- go.mod | 4 ++-- go.sum | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 3ff6c71f9f10..845d086063cb 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/fatih/color v1.15.0 github.com/firefart/nonamedreturns v1.0.4 github.com/fzipp/gocyclo v0.6.0 - github.com/go-critic/go-critic v0.6.7 + github.com/go-critic/go-critic v0.7.0 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/gofrs/flock v0.8.1 github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 @@ -161,7 +161,7 @@ require ( github.com/prometheus/procfs v0.7.3 // indirect github.com/quasilyte/go-ruleguard v0.3.19 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect - github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect + github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/sivchari/nosnakecase v1.7.0 github.com/spf13/afero v1.8.2 // indirect diff --git a/go.sum b/go.sum index 3c83e50a551e..388458cd63a8 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/go-critic/go-critic v0.6.7 h1:1evPrElnLQ2LZtJfmNDzlieDhjnq36SLgNzisx06oPM= -github.com/go-critic/go-critic v0.6.7/go.mod h1:fYZUijFdcnxgx6wPjQA2QEjIRaNCT0gO8bhexy6/QmE= +github.com/go-critic/go-critic v0.7.0 h1:tqbKzB8pqi0NsRZ+1pyU4aweAF7A7QN0Pi4Q02+rYnQ= +github.com/go-critic/go-critic v0.7.0/go.mod h1:moYzd7GdVXE2C2hYTwd7h0CPcqlUeclsyBRwMa38v64= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -162,7 +162,7 @@ github.com/go-toolsmith/astfmt v1.1.0 h1:iJVPDPp6/7AaeLJEruMsBUlOYCmvg0MoCfJprsO github.com/go-toolsmith/astfmt v1.1.0/go.mod h1:OrcLlRwu0CuiIBp/8b5PYF9ktGVZUjlNMV634mhwuQ4= github.com/go-toolsmith/astp v1.1.0 h1:dXPuCl6u2llURjdPLLDxJeZInAeZ0/eZwFJmqZMnpQA= github.com/go-toolsmith/astp v1.1.0/go.mod h1:0T1xFGz9hicKs8Z5MfAqSUitoUYS30pDMsRVIDHs8CA= -github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5 h1:eD9POs68PHkwrx7hAB78z1cb6PfGq/jyWn3wJywsH1o= +github.com/go-toolsmith/pkgload v1.2.2 h1:0CtmHq/02QhxcF7E9N5LIFcYFsMR5rdovfqTtRKkgIk= github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQiyP2Bvw= github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= @@ -441,8 +441,8 @@ github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo= github.com/quasilyte/gogrep v0.5.0/go.mod h1:Cm9lpz9NZjEoL1tgZ2OgeUKPIxL1meE7eo60Z6Sk+Ng= -github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 h1:L8QM9bvf68pVdQ3bCFZMDmnt9yqcMBro1pC7F+IPYMY= -github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= +github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl980XxGFEZSS6KlBGIV0diGdySzxATTWoqaU= +github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= From 5f4699c8afc1e97c8d0086c042b4dbe0d795ddc3 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 17 Mar 2023 10:00:17 +0100 Subject: [PATCH 2/5] Fix linter suggestion --- test/bench/bench_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index c96d14a37453..1a00ccd0b152 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -26,8 +26,10 @@ func chdir(b *testing.B, dir string) { } } -func prepareGoSource(b *testing.B) { - chdir(b, filepath.Join(build.Default.GOROOT, "src")) +func prepareGoSource() func(b *testing.B) { + return func(b *testing.B) { + chdir(b, filepath.Join(build.Default.GOROOT, "src")) + } } func prepareGithubProject(owner, name string) func(*testing.B) { @@ -79,13 +81,15 @@ func getGolangciLintCommonArgs() []string { return []string{"run", "--no-config", "--issues-exit-code=0", "--deadline=30m", "--disable-all", "--enable=govet"} } -func runGolangciLintForBench(b *testing.B) { - args := getGolangciLintCommonArgs() - args = append(args, getBenchLintersArgs()...) - printCommand("golangci-lint", args...) - out, err := exec.Command("golangci-lint", args...).CombinedOutput() - if err != nil { - b.Fatalf("can't run golangci-lint: %s, %s", err, out) +func runGolangciLintForBench() func(b *testing.B) { + return func(b *testing.B) { + args := getGolangciLintCommonArgs() + args = append(args, getBenchLintersArgs()...) + printCommand("golangci-lint", args...) + out, err := exec.Command("golangci-lint", args...).CombinedOutput() + if err != nil { + b.Fatalf("can't run golangci-lint: %s, %s", err, out) + } } } @@ -229,13 +233,13 @@ func BenchmarkGolangciLint(b *testing.B) { }, { name: "go source code", - prepare: prepareGoSource, + prepare: prepareGoSource(), }, } for _, bc := range bcases { bc.prepare(b) lc := getGoLinesTotalCount(b) - result := runOne(b, runGolangciLintForBench, "golangci-lint") + result := runOne(b, runGolangciLintForBench(), "golangci-lint") log.Printf("%s (%d kLoC): time: %s, memory: %dMB", bc.name, lc/1000, From f4cb0d981d680494cffbeebb907a4626c9457c7d Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 17 Mar 2023 10:16:58 +0100 Subject: [PATCH 3/5] Rename bench helpers --- test/bench/bench_test.go | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index 1a00ccd0b152..5ad088c37982 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -26,10 +26,8 @@ func chdir(b *testing.B, dir string) { } } -func prepareGoSource() func(b *testing.B) { - return func(b *testing.B) { - chdir(b, filepath.Join(build.Default.GOROOT, "src")) - } +func benchPrepareGoSource(b *testing.B) { + chdir(b, filepath.Join(build.Default.GOROOT, "src")) } func prepareGithubProject(owner, name string) func(*testing.B) { @@ -81,15 +79,13 @@ func getGolangciLintCommonArgs() []string { return []string{"run", "--no-config", "--issues-exit-code=0", "--deadline=30m", "--disable-all", "--enable=govet"} } -func runGolangciLintForBench() func(b *testing.B) { - return func(b *testing.B) { - args := getGolangciLintCommonArgs() - args = append(args, getBenchLintersArgs()...) - printCommand("golangci-lint", args...) - out, err := exec.Command("golangci-lint", args...).CombinedOutput() - if err != nil { - b.Fatalf("can't run golangci-lint: %s, %s", err, out) - } +func benchRunGolangciLintForBench(b *testing.B) { + args := getGolangciLintCommonArgs() + args = append(args, getBenchLintersArgs()...) + printCommand("golangci-lint", args...) + out, err := exec.Command("golangci-lint", args...).CombinedOutput() + if err != nil { + b.Fatalf("can't run golangci-lint: %s, %s", err, out) } } @@ -233,13 +229,13 @@ func BenchmarkGolangciLint(b *testing.B) { }, { name: "go source code", - prepare: prepareGoSource(), + prepare: benchPrepareGoSource, }, } for _, bc := range bcases { bc.prepare(b) lc := getGoLinesTotalCount(b) - result := runOne(b, runGolangciLintForBench(), "golangci-lint") + result := runOne(b, benchRunGolangciLintForBench, "golangci-lint") log.Printf("%s (%d kLoC): time: %s, memory: %dMB", bc.name, lc/1000, From 535d9c3d424a09dd3a2b65a960d7f0bfddb5c2ef Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 17 Mar 2023 10:32:25 +0100 Subject: [PATCH 4/5] Just change func param --- test/bench/bench_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/bench/bench_test.go b/test/bench/bench_test.go index 5ad088c37982..a6ef3fe2184e 100644 --- a/test/bench/bench_test.go +++ b/test/bench/bench_test.go @@ -20,18 +20,18 @@ import ( "github.com/golangci/golangci-lint/test/testshared" ) -func chdir(b *testing.B, dir string) { +func chdir(b testing.TB, dir string) { if err := os.Chdir(dir); err != nil { b.Fatalf("can't chdir to %s: %s", dir, err) } } -func benchPrepareGoSource(b *testing.B) { +func prepareGoSource(b testing.TB) { chdir(b, filepath.Join(build.Default.GOROOT, "src")) } -func prepareGithubProject(owner, name string) func(*testing.B) { - return func(b *testing.B) { +func prepareGithubProject(owner, name string) func(testing.TB) { + return func(b testing.TB) { dir := filepath.Join(build.Default.GOPATH, "src", "github.com", owner, name) _, err := os.Stat(dir) if os.IsNotExist(err) { @@ -79,7 +79,7 @@ func getGolangciLintCommonArgs() []string { return []string{"run", "--no-config", "--issues-exit-code=0", "--deadline=30m", "--disable-all", "--enable=govet"} } -func benchRunGolangciLintForBench(b *testing.B) { +func runGolangciLintForBench(b testing.TB) { args := getGolangciLintCommonArgs() args = append(args, getBenchLintersArgs()...) printCommand("golangci-lint", args...) @@ -180,7 +180,7 @@ type runResult struct { duration time.Duration } -func runOne(b *testing.B, run func(*testing.B), progName string) *runResult { +func runOne(b *testing.B, run func(testing.TB), progName string) *runResult { doneCh := make(chan struct{}) peakMemCh := trackPeakMemoryUsage(b, doneCh, progName) startedAt := time.Now() @@ -200,7 +200,7 @@ func BenchmarkGolangciLint(b *testing.B) { type bcase struct { name string - prepare func(*testing.B) + prepare func(testing.TB) } bcases := []bcase{ { @@ -229,13 +229,13 @@ func BenchmarkGolangciLint(b *testing.B) { }, { name: "go source code", - prepare: benchPrepareGoSource, + prepare: prepareGoSource, }, } for _, bc := range bcases { bc.prepare(b) lc := getGoLinesTotalCount(b) - result := runOne(b, benchRunGolangciLintForBench, "golangci-lint") + result := runOne(b, runGolangciLintForBench, "golangci-lint") log.Printf("%s (%d kLoC): time: %s, memory: %dMB", bc.name, lc/1000, From 6a5719b0d1f2767f7d077c8d4073977afbe5bbed Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Fri, 17 Mar 2023 10:34:06 +0100 Subject: [PATCH 5/5] Use newer import --- pkg/golinters/gocritic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/golinters/gocritic.go b/pkg/golinters/gocritic.go index ed9681a308bf..2e241b5a1862 100644 --- a/pkg/golinters/gocritic.go +++ b/pkg/golinters/gocritic.go @@ -13,7 +13,7 @@ import ( "sync" "github.com/go-critic/go-critic/checkers" - gocriticlinter "github.com/go-critic/go-critic/framework/linter" + gocriticlinter "github.com/go-critic/go-critic/linter" "golang.org/x/tools/go/analysis" "github.com/golangci/golangci-lint/pkg/config"