Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unhandled-error: use full function name in error message #962

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rule/unhandled-error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}

Expand Down
6 changes: 3 additions & 3 deletions testdata/unhandled-error-w-ignorelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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/
}
Loading