From a7e2cceb73e613cee25f7ed348855a6e0afe56ab Mon Sep 17 00:00:00 2001 From: Michael McLoughlin Date: Sun, 7 Jan 2024 15:40:15 -0500 Subject: [PATCH 1/3] update tests --- rule/unhandled-error.go | 2 +- testdata/unhandled-error-w-ignorelist.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rule/unhandled-error.go b/rule/unhandled-error.go index 32a5fe48b..ce6fa3864 100644 --- a/rule/unhandled-error.go +++ b/rule/unhandled-error.go @@ -119,7 +119,7 @@ func (w *lintUnhandledErrors) addFailure(n *ast.CallExpr) { Category: "bad practice", Confidence: 1, Node: n, - Failure: fmt.Sprintf("Unhandled error in call to function %v", gofmt(n.Fun)), + Failure: fmt.Sprintf("Unhandled error in call to function %v", name), }) } diff --git a/testdata/unhandled-error-w-ignorelist.go b/testdata/unhandled-error-w-ignorelist.go index e1050c48c..5f21dc0d7 100644 --- a/testdata/unhandled-error-w-ignorelist.go +++ b/testdata/unhandled-error-w-ignorelist.go @@ -56,7 +56,7 @@ func testCase4() { b1.Write(nil) // ignore b2.Write(nil) // ignore - b2.Read([]byte("bytes")) // MATCH /Unhandled error in call to function b2.Read/ + b2.Read([]byte("bytes")) // MATCH /Unhandled error in call to function bytes.Buffer.Read/ } type unhandledErrorStruct1 struct { @@ -81,9 +81,9 @@ func testCase5() { // fixtures\.unhandledErrorStruct2\.reterr s1 := unhandledErrorStruct1{} _ = s1.reterr() - s1.reterr() // MATCH /Unhandled error in call to function s1.reterr/ + s1.reterr() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct1.reterr/ s2 := unhandledErrorStruct2{} s2.reterr() // ignore - s2.reterr1() // MATCH /Unhandled error in call to function s2.reterr1/ + s2.reterr1() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct2.reterr1/ } From 96d7db7decec6225fe5d61eacd5c5ddf7db5cdbc Mon Sep 17 00:00:00 2001 From: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com> Date: Mon, 8 Jan 2024 10:20:35 +0100 Subject: [PATCH 2/3] Update testdata/unhandled-error-w-ignorelist.go --- testdata/unhandled-error-w-ignorelist.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testdata/unhandled-error-w-ignorelist.go b/testdata/unhandled-error-w-ignorelist.go index 5f21dc0d7..0991c3159 100644 --- a/testdata/unhandled-error-w-ignorelist.go +++ b/testdata/unhandled-error-w-ignorelist.go @@ -87,3 +87,10 @@ func testCase5() { s2.reterr() // ignore s2.reterr1() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct2.reterr1/ } + +func testCase6() { + f := func() error { + return nil + } + f() // MATCH /Unhandled error in call to function f/ +} From 4481d831b1d275ecbb7fbc7b1e89bdaf399b030d Mon Sep 17 00:00:00 2001 From: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com> Date: Mon, 8 Jan 2024 10:24:17 +0100 Subject: [PATCH 3/3] Update testdata/unhandled-error-w-ignorelist.go --- testdata/unhandled-error-w-ignorelist.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/testdata/unhandled-error-w-ignorelist.go b/testdata/unhandled-error-w-ignorelist.go index 0991c3159..5f21dc0d7 100644 --- a/testdata/unhandled-error-w-ignorelist.go +++ b/testdata/unhandled-error-w-ignorelist.go @@ -87,10 +87,3 @@ func testCase5() { s2.reterr() // ignore s2.reterr1() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct2.reterr1/ } - -func testCase6() { - f := func() error { - return nil - } - f() // MATCH /Unhandled error in call to function f/ -}