*: 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 <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2023-09-21 12:30:23 +08:00
parent 9c3edfa0af
commit 2b1e181c8b
5 changed files with 15 additions and 28 deletions

View File

@@ -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}" <<EOF
---
run:
@@ -453,7 +448,13 @@ issues:
linters: [ineffassign]
linters:
disable-all: true
enable:
enable: # please keep this alphabetized
# Don't use soon to deprecated[1] linters that lead to false
# https://github.com/golangci/golangci-lint/issues/1841
# - deadcode
# - structcheck
# - varcheck
- ineffassign
- staticcheck
linters-settings:
staticcheck:
@@ -476,10 +477,6 @@ function unconvert_pass {
run_for_modules generic_checker run_go_tool "github.com/mdempsky/unconvert" unconvert -v
}
function ineffassign_pass {
run_for_modules generic_checker run_go_tool "github.com/gordonklaus/ineffassign"
}
function nakedret_pass {
run_for_modules generic_checker run_go_tool "github.com/alexkohler/nakedret/cmd/nakedret"
}