From f49997bb98fc282b48f8b6b2c3bd6ac3549b9f1a Mon Sep 17 00:00:00 2001 From: Steven Danna Date: Tue, 23 Mar 2021 11:45:32 +0000 Subject: [PATCH] lint: don't use -unused.whole-program when PKG is specified The unused linter's whole program mode will create false-positives when PKG is specified. As a result, anyone trying to use make lint PKG=./pkg/SOMETHING has to carefully read the failure output to see if it was actually a success. By not passing that flag when PKG is specified, more cases of the above command complete without erroneous findings. Release note: None --- pkg/testutils/lint/lint_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 895ff1f28f2b..e5ef4accd487 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -1608,12 +1608,16 @@ func TestLint(t *testing.T) { t.Run("TestStaticCheck", func(t *testing.T) { // staticcheck uses 2.4GB of ram (as of 2019-05-10), so don't parallelize it. skip.UnderShort(t) + var args []string + if pkgSpecified { + args = []string{pkgScope} + } else { + args = []string{"-unused.whole-program", pkgScope} + } cmd, stderr, filter, err := dirCmd( crdb.Dir, "staticcheck", - "-unused.whole-program", - pkgScope, - ) + args...) if err != nil { t.Fatal(err) }