Open
Description
Currently, the unclosetx
check detects unclosed transactions.
However, in test code, it is becoming more common to close transactions using t.Cleanup.
tx := client.ReadOnlyTransaction()
t.Cleanup(tx.Close)
// ...
t.Cleanup is a method that registers a cleanup function to be executed at the end of the test function. It is similar to defer, but it ensures that the cleanup function runs only after all parallel subtests have completed.
However, the current unclosetx check considers transactions closed inside t.Cleanup as unclosed, leading to false positives.
To improve this, I would like to propose modifying the unclosetx
check to exclude transactions that are closed inside t.Cleanup, similar to how it already handles defer.
Would this be a feasible enhancement?
Metadata
Metadata
Assignees
Labels
No labels