From 2b1e181c8b34a42bcd8ca730b969e5cf8c39d5c0 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Thu, 21 Sep 2023 12:30:23 +0800 Subject: [PATCH] *: Use golangcilint_pass to run staticcheck and ineffassign Copy the tools/.golangci.yaml and run the linters for which we have already fixed. The temp .golangci.yaml will be removed when we fixes all the linters' issues. Signed-off-by: Wei Fu --- Makefile | 8 ++++---- scripts/test.sh | 25 +++++++++++-------------- tools/mod/go.mod | 1 - tools/mod/go.sum | 8 -------- tools/mod/tools.go | 1 - 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 0e8f90b79..249fad34f 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ verify-dep: # still depends on legacy {ineffassign,nakedret,unparam,...}_pass. These X_pass # will be removed when the golangci-lint covers all the sub modules. .PHONY: verify-lint -verify-lint: verify-ineffassign +verify-lint: verify-golangcilint golangci-lint run --config tools/.golangci.yaml .PHONY: fix-lint @@ -150,9 +150,9 @@ verify-yamllint: verify-govet-shadow: PASSES="govet_shadow" ./scripts/test.sh -.PHONY: verify-ineffassign -verify-ineffassign: - PASSES="ineffassign" ./scripts/test.sh +.PHONY: verify-golangcilint +verify-golangcilint: + PASSES="golangcilint" ./scripts/test.sh YAMLFMT_VERSION = $(shell cd tools/mod && go list -m -f '{{.Version}}' github.com/google/yamlfmt) diff --git a/scripts/test.sh b/scripts/test.sh index 83347fdf4..f79268f97 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -425,20 +425,15 @@ function unparam_pass { run_for_modules generic_checker run_go_tool "mvdan.cc/unparam" } -function staticcheck_pass { +function golangcilint_pass { local tmp_lintyaml - tmp_lintyaml=$(mktemp -t 'tmp_golangcilint_staticcheckXXX.yaml') + tmp_lintyaml=$(mktemp -t 'tmp_golangcilint_XXX.yaml') # shellcheck disable=SC2064 trap "rm ${tmp_lintyaml}; trap - RETURN" RETURN - # TODO: The golangci-lint commandline doesn't support listener-settings. And - # staticcheck command[1] not just verifies the staticcheck, but also includes - # stylecheck and unused. So copy the tools/.golangci.yaml and just run the - # staticcheck rule. It should be removed when closes #16610 - # - # REF: - # [1] https://github.com/dominikh/go-tools/blob/v0.4.5/cmd/staticcheck/staticcheck.go#L29 + # TODO: Copy the tools/.golangci.yaml and run the linters for which we have + # already fixed. It should be removed when closes #16610. cat > "${tmp_lintyaml}" <