From 7da792013296a552bfc442bc537994c68bd21a06 Mon Sep 17 00:00:00 2001 From: "user.name: \"Omer Hasson" Date: Wed, 19 Jun 2024 14:12:45 +0300 Subject: [PATCH] expand lint rule to avoid dealing with context.WithCancel cases --- scripts/vet.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/vet.sh b/scripts/vet.sh index 7dac4c9ffdd5..32f3d02f03af 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -50,8 +50,8 @@ not grep 'func Test[^(]' -- test/*.go git grep 'func (s) ' -- "*_test.go" | not grep -v 'func (s) Test' git grep 'func [A-Z]' -- "*_test.go" | not grep -v 'func Test\|Benchmark\|Example' -# - Make sure not context usage are done without timeout. -git grep 'context.Background()' -- "*_test.go" | not grep -v 'context.WithTimeout(context.Background()' +# - Make sure all context usages are done timeout. +git grep -e 'context.Background()' --or -e 'context.TODO()' -- "*_test.go" | not grep -v 'context.WithTimeout(context.Background()' | not grep -v 'context.WithCancel(context.Background' | not grep -v 'context.WithTimeOut(context.TODO()' # - Do not use time.After except in tests. It has the potential to leak the # timer since there is no way to stop it early.