From c40cb837722b80c5d1c5a10e0ca18ef378f68104 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Fri, 1 Nov 2024 17:20:37 +0400 Subject: [PATCH 1/3] chore: bump golangci-lint Signed-off-by: knqyf263 --- magefiles/magefile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magefiles/magefile.go b/magefiles/magefile.go index f70491bce2e8..5b08e907f0c0 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -77,7 +77,7 @@ func (Tool) Wire() error { // GolangciLint installs golangci-lint func (t Tool) GolangciLint() error { - const version = "v1.59.1" + const version = "v1.61.0" bin := filepath.Join(GOBIN, "golangci-lint") if exists(bin) && t.matchGolangciLintVersion(bin, version) { return nil From 9f4748f1f801cef74d89291f2f84255ac0312ffa Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Fri, 1 Nov 2024 17:20:55 +0400 Subject: [PATCH 2/3] refactor: address lint issues Signed-off-by: knqyf263 --- .golangci.yaml | 1 + pkg/fanal/walker/walk_test.go | 19 ++++++++++++------- pkg/plugin/index.go | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 40bfa36e1a64..b6dbc299be20 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -68,6 +68,7 @@ linters-settings: excludes: - G101 - G114 + - G115 - G204 - G304 - G402 diff --git a/pkg/fanal/walker/walk_test.go b/pkg/fanal/walker/walk_test.go index 09d55527c0fe..3c066529393f 100644 --- a/pkg/fanal/walker/walk_test.go +++ b/pkg/fanal/walker/walk_test.go @@ -1,7 +1,6 @@ package walker_test import ( - "fmt" "path/filepath" "testing" @@ -42,8 +41,11 @@ func TestSkipFile(t *testing.T) { }, }, { - name: "multiple skip files", - skipFiles: []string{"/etc/*/*", "/var/log/*.txt"}, + name: "multiple skip files", + skipFiles: []string{ + "/etc/*/*", + "/var/log/*.txt", + }, wants: map[string]bool{ "/etc/foo": false, "/etc/foo/bar": true, @@ -65,7 +67,7 @@ func TestSkipFile(t *testing.T) { for file, want := range tt.wants { file = filepath.ToSlash(filepath.Clean(file)) got := utils.SkipPath(file, utils.CleanSkipPaths(tt.skipFiles)) - assert.Equal(t, want, got, fmt.Sprintf("skipFiles: %s, file: %s", tt.skipFiles, file)) + assert.Equal(t, want, got, "skipFiles: %s, file: %s", tt.skipFiles, file) } }) } @@ -108,8 +110,11 @@ func TestSkipDir(t *testing.T) { }, }, { - name: "multiple dirs", - skipDirs: []string{"/etc/*/*", "/var/log/*"}, + name: "multiple dirs", + skipDirs: []string{ + "/etc/*/*", + "/var/log/*", + }, wants: map[string]bool{ "/etc/foo": false, "/etc/foo/bar": true, @@ -139,7 +144,7 @@ func TestSkipDir(t *testing.T) { for dir, want := range tt.wants { dir = filepath.ToSlash(filepath.Clean(dir)) got := utils.SkipPath(dir, utils.CleanSkipPaths(tt.skipDirs)) - assert.Equal(t, want, got, fmt.Sprintf("defaultSkipDirs: %s, dir: %s", tt.skipDirs, dir)) + assert.Equal(t, want, got, "defaultSkipDirs: %s, dir: %s", tt.skipDirs, dir) } }) } diff --git a/pkg/plugin/index.go b/pkg/plugin/index.go index 57c6f0260877..82e4cb076356 100644 --- a/pkg/plugin/index.go +++ b/pkg/plugin/index.go @@ -61,7 +61,7 @@ func (m *Manager) Search(ctx context.Context, keyword string) error { } } - if _, err = fmt.Fprintf(m.w, buf.String()); err != nil { + if _, err = fmt.Fprint(m.w, buf.String()); err != nil { return err } From b244893e9fa4210d7e6decf8b47192af92beaf65 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Fri, 1 Nov 2024 21:06:18 +0400 Subject: [PATCH 3/3] ci: bump golangci-lint Signed-off-by: knqyf263 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 05edadf93331..c2af5eb66bbb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -42,7 +42,7 @@ jobs: id: lint uses: golangci/golangci-lint-action@v6.0.1 with: - version: v1.59 + version: v1.61 args: --verbose --out-format=line-number if: matrix.operating-system == 'ubuntu-latest'