Open
Description
Proposal Details
I noticed recently during a code review that t.Cleanup
was being deferred, which is almost certainly unintentional.
func TestABC(t *testing.T) {
defer t.Cleanup(func() {
// ...
})
}
A naive search shows hundreds of results, and it's possible a more accurate search would show even more.
https://github.com/search?q=%22defer+t.Cleanup%28func%22+language%3AGo&type=code
It would be nice to have an analyser to catch this as I am not sure I see any scenario where this is actually desirable.