Skip to content

Commit be35a88

Browse files
unhandled-error: use full function name in error message (#962)
* update tests * Update testdata/unhandled-error-w-ignorelist.go * Update testdata/unhandled-error-w-ignorelist.go --------- Co-authored-by: Denis Voytyuk <[email protected]>
1 parent 4b62e4b commit be35a88

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rule/unhandled-error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (w *lintUnhandledErrors) addFailure(n *ast.CallExpr) {
119119
Category: "bad practice",
120120
Confidence: 1,
121121
Node: n,
122-
Failure: fmt.Sprintf("Unhandled error in call to function %v", gofmt(n.Fun)),
122+
Failure: fmt.Sprintf("Unhandled error in call to function %v", name),
123123
})
124124
}
125125

testdata/unhandled-error-w-ignorelist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func testCase4() {
5656
b1.Write(nil) // ignore
5757
b2.Write(nil) // ignore
5858

59-
b2.Read([]byte("bytes")) // MATCH /Unhandled error in call to function b2.Read/
59+
b2.Read([]byte("bytes")) // MATCH /Unhandled error in call to function bytes.Buffer.Read/
6060
}
6161

6262
type unhandledErrorStruct1 struct {
@@ -81,9 +81,9 @@ func testCase5() {
8181
// fixtures\.unhandledErrorStruct2\.reterr
8282
s1 := unhandledErrorStruct1{}
8383
_ = s1.reterr()
84-
s1.reterr() // MATCH /Unhandled error in call to function s1.reterr/
84+
s1.reterr() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct1.reterr/
8585

8686
s2 := unhandledErrorStruct2{}
8787
s2.reterr() // ignore
88-
s2.reterr1() // MATCH /Unhandled error in call to function s2.reterr1/
88+
s2.reterr1() // MATCH /Unhandled error in call to function fixtures.unhandledErrorStruct2.reterr1/
8989
}

0 commit comments

Comments
 (0)