From 5f7f4b3a853dcc483a9bd1d66b1fb4c04ca6ca29 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 10 Dec 2024 11:38:48 +0100 Subject: [PATCH] Update golangci-lint to v1.62 Signed-off-by: Sascha Grunert --- .github/workflows/lint.yml | 2 +- .golangci.yml | 2 ++ cmd/krel/cmd/release_notes.go | 22 +++++++++++++++------- dependencies.yaml | 2 +- pkg/cve/cve.go | 4 +++- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5e082d7df25..b2d08a00f0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,4 +25,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 with: - version: v1.61 + version: v1.62 diff --git a/.golangci.yml b/.golangci.yml index ceb26b491b1..bf43b0fd906 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -55,6 +55,7 @@ linters: - gosmopolitan - govet - grouper + - iface - importas - ineffassign - intrange @@ -72,6 +73,7 @@ linters: - promlinter - protogetter - reassign + - recvcheck - revive - rowserrcheck - sloglint diff --git a/cmd/krel/cmd/release_notes.go b/cmd/krel/cmd/release_notes.go index 25589cb3a4d..f4f2ccc7a63 100644 --- a/cmd/krel/cmd/release_notes.go +++ b/cmd/krel/cmd/release_notes.go @@ -1184,7 +1184,8 @@ func fixReleaseNotes(workDir string, releaseNotes *notes.ReleaseNotes) error { _, choice, err := util.Ask(fmt.Sprintf("\n- Fix note for PR #%d? (y/N)", note.PrNumber), "y:Y:yes|n:N:no|n", 10) if err != nil { // If the user cancelled with ctr+c exit and continue the PR flow - if err.(util.UserInputError).IsCtrlC() { + var userInputErr util.UserInputError + if errors.As(err, &userInputErr) && userInputErr.IsCtrlC() { logrus.Info("Input cancelled, exiting edit flow") return nil } @@ -1240,8 +1241,10 @@ func fixReleaseNotes(workDir string, releaseNotes *notes.ReleaseNotes) error { func pointIfChanged(label string, var1, var2 interface{}) string { changed := false // Check if alues are string - if _, ok := var1.(string); ok { - if var1.(string) != var2.(string) { + var1String, ok1 := var1.(string) + var2String, ok2 := var2.(string) + if ok1 && ok2 { + if var1String != var2String { changed = true } } @@ -1253,9 +1256,11 @@ func pointIfChanged(label string, var1, var2 interface{}) string { } } - // Check if string slices - if _, ok := var1.(bool); ok { - if var1.(bool) != var2.(bool) { + // Check if bools + var1Bool, ok1 := var1.(bool) + var2Bool, ok2 := var2.(bool) + if ok1 && ok2 { + if var1Bool != var2Bool { changed = true } } @@ -1458,9 +1463,12 @@ func confirmWithUser(opts *releaseNotesOptions, question string) bool { _, success, err := util.Ask(question+" (Y/n)", "y:Y:yes|n:N:no|y", 10) if err != nil { logrus.Error(err) - if err.(util.UserInputError).IsCtrlC() { + + var userInputErr util.UserInputError + if errors.As(err, &userInputErr) && userInputErr.IsCtrlC() { os.Exit(1) } + return false } if success { diff --git a/dependencies.yaml b/dependencies.yaml index b3da8e0ba9e..94e007f00cc 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -371,7 +371,7 @@ dependencies: # golangci-lint-version - name: "golangci-lint" - version: v1.61 + version: v1.62 refPaths: - path: .github/workflows/lint.yml match: "version: v\\d+.\\d+?\\.?(\\d+)?" diff --git a/pkg/cve/cve.go b/pkg/cve/cve.go index 8eca98a870d..3734c34edc0 100644 --- a/pkg/cve/cve.go +++ b/pkg/cve/cve.go @@ -65,7 +65,9 @@ func (cve *CVE) ReadRawInterface(cvedata interface{}) error { if val, ok := cvedata.(map[interface{}]interface{})["linkedPRs"].([]interface{}); ok { cve.LinkedPRs = []int{} for _, prid := range val { - cve.LinkedPRs = append(cve.LinkedPRs, prid.(int)) + if prid, ok := prid.(int); ok { + cve.LinkedPRs = append(cve.LinkedPRs, prid) + } } }