Closed
Description
The premise is that we want tests to use defer
so that they read like idiomatic Go code and that there is no mixed usage of defer
and t.Cleanup
(since the order of execution is hard to reason about, and rarely the intent). The exception is test helper functions.
This was requested in #3113 but not required for merging the PR.
A few examples for ruleguard rules was floated in #3113 but both have unnecessary repercussions:
- Simple rule is too aggressive
- More specific rule does not catch non-toplevel uses (e.g. if the
t.Cleanup
is insideif {}
it won't be caught