From 6ee59e52f2a83a057deba70accac6e9fc81bd6c4 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 7 Mar 2021 05:00:18 +0100 Subject: [PATCH 1/2] Deprecate scopelint linter --- pkg/lint/lintersdb/manager.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 5f1b1f0f5a45..6dd28f05de02 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -271,7 +271,8 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { WithURL("https://github.com/alexkohler/prealloc"), linter.NewConfig(golinters.NewScopelint()). WithPresets(linter.PresetBugs). - WithURL("https://github.com/kyoh86/scopelint"), + WithURL("https://github.com/kyoh86/scopelint"). + Deprecated("The repository of the linter has been deprecated by the owner. Use 'exportloopref' instead."), linter.NewConfig(golinters.NewGocritic()). WithPresets(linter.PresetStyle). WithLoadForGoAnalysis(). From b740afc18a5921fe340b5dcce8668e47d0a01673 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 9 Mar 2021 19:08:06 +0100 Subject: [PATCH 2/2] clean code base. --- .golangci.yml | 3 ++- go.sum | 1 - pkg/golinters/gofmt_common.go | 2 +- pkg/result/processors/fixer.go | 2 +- pkg/result/processors/path_prefixer_test.go | 6 +++--- test/run_test.go | 4 ++-- test/testdata/scopelint.go | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f2fcc17cc0fa..d625ff8047d8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -73,6 +73,7 @@ linters: - dogsled - dupl - errcheck + - exportloopref - exhaustive - funlen - gochecknoinits @@ -94,7 +95,6 @@ linters: - noctx - nolintlint - rowserrcheck - - scopelint - staticcheck - structcheck - stylecheck @@ -107,6 +107,7 @@ linters: # don't enable: # - asciicheck + # - scopelint # - gochecknoglobals # - gocognit # - godot diff --git a/go.sum b/go.sum index 52801bb7d00a..1ea9edb0d43c 100644 --- a/go.sum +++ b/go.sum @@ -546,7 +546,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210217105451-b926d437f341 h1:2/QtM1mL37YmcsT8HaDNHDgTqqFVw+zr8UzMiBVLzYU= golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/pkg/golinters/gofmt_common.go b/pkg/golinters/gofmt_common.go index 3235622e8bf5..39e8092e9735 100644 --- a/pkg/golinters/gofmt_common.go +++ b/pkg/golinters/gofmt_common.go @@ -176,7 +176,7 @@ func (p *hunkChangesParser) parse(h *diffpkg.Hunk) []Change { for i := 0; i < len(p.lines); { line := p.lines[i] if line.typ == diffLineOriginal { - p.handleOriginalLine(line, &i) //nolint:scopelint + p.handleOriginalLine(line, &i) continue } diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index 75fdc93f1003..17f519e32ba1 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -57,7 +57,7 @@ func (f Fixer) Process(issues []result.Issue) []result.Issue { for file, issuesToFix := range issuesToFixPerFile { var err error f.sw.TrackStage("all", func() { - err = f.fixIssuesInFile(file, issuesToFix) //nolint:scopelint + err = f.fixIssuesInFile(file, issuesToFix) }) if err != nil { f.log.Errorf("Failed to fix issues in file %s: %s", file, err) diff --git a/pkg/result/processors/path_prefixer_test.go b/pkg/result/processors/path_prefixer_test.go index e4b4c86e30af..55fdbea9264c 100644 --- a/pkg/result/processors/path_prefixer_test.go +++ b/pkg/result/processors/path_prefixer_test.go @@ -27,11 +27,11 @@ func TestPathPrefixer_Process(t *testing.T) { t.Run(tt.name, func(t *testing.T) { r := require.New(t) - p := NewPathPrefixer(tt.prefix) //nolint:scopelint - got, err := p.Process(tt.issues) //nolint:scopelint + p := NewPathPrefixer(tt.prefix) + got, err := p.Process(tt.issues) r.NoError(err, "prefixer should never error") - r.Equal(got, tt.want) //nolint:scopelint + r.Equal(got, tt.want) }) } } diff --git a/test/run_test.go b/test/run_test.go index 34a0736651f5..e644b2e93bb1 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -337,9 +337,9 @@ func TestPathPrefix(t *testing.T) { } { t.Run(tt.Name, func(t *testing.T) { testshared.NewLintRunner(t).Run( - append(tt.Args, getTestDataDir("withtests"))..., //nolint:scopelint + append(tt.Args, getTestDataDir("withtests"))..., ).ExpectOutputRegexp( - tt.Pattern, //nolint:scopelint + tt.Pattern, ) }) } diff --git a/test/testdata/scopelint.go b/test/testdata/scopelint.go index 346387f4c213..1404841a6bc0 100644 --- a/test/testdata/scopelint.go +++ b/test/testdata/scopelint.go @@ -1,4 +1,4 @@ -//args: -Escopelint +//args: -Escopelint --internal-cmd-test package testdata import "fmt"