dgryski / semgrep-go

Go rules for semgrep and go-ruleguard
MIT License
457 stars 37 forks source link

add t.Cleanup to contextCancelable #65

Closed dmitris closed 5 months ago

dmitris commented 6 months ago

I'm getting the following code in test being flagged with cancelable-context-not-systematically-cancelled:

    test: func(t *testing.T) {
        ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
        t.Cleanup(cancel)

which seems a clear false positive - test.Cleanup. With the suggest change, those code snippets are not in the flagged issues.