*: lint_pass should use global golangci.yaml

Disable failed linters and enable it by #16610.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2023-09-21 15:08:42 +08:00
parent 2b1e181c8b
commit 502879405f
3 changed files with 9 additions and 56 deletions

View File

@ -85,14 +85,9 @@ fix-bom:
verify-dep:
PASSES="dep" ./scripts/test.sh
# TODO: https://github.com/etcd-io/etcd/issues/16610
#
# The golangci-lint doesn't verify sub modules. Before #16610 fixed, verify-lint
# 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-golangcilint
golangci-lint run --config tools/.golangci.yaml
verify-lint:
PASSES="lint" ./scripts/test.sh
.PHONY: fix-lint
fix-lint:
@ -150,10 +145,6 @@ verify-yamllint:
verify-govet-shadow:
PASSES="govet_shadow" ./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)
.PHONY: fix-yamllint

View File

@ -425,46 +425,8 @@ function unparam_pass {
run_for_modules generic_checker run_go_tool "mvdan.cc/unparam"
}
function golangcilint_pass {
local tmp_lintyaml
tmp_lintyaml=$(mktemp -t 'tmp_golangcilint_XXX.yaml')
# shellcheck disable=SC2064
trap "rm ${tmp_lintyaml}; trap - RETURN" RETURN
# 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:
timeout: 30m
skip-files: [^zz_generated.*]
issues:
max-same-issues: 0
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# exclude ineffassing linter for generated files for conversion
- path: conversion\.go
linters: [ineffassign]
linters:
disable-all: true
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:
checks:
- all
- -SA1019 # TODO(fix) Using a deprecated function, variable, constant or field
- -SA2002 # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isn't allowed
EOF
run_for_modules generic_checker run golangci-lint run --config "${tmp_lintyaml}"
function lint_pass {
run_for_modules generic_checker run golangci-lint run --config "${ETCD_ROOT_DIR}/tools/.golangci.yaml"
}
function revive_pass {

View File

@ -17,13 +17,13 @@ linters:
# - deadcode
# - structcheck
# - varcheck
- goimports
# - goimports # TODO: enable by #16610
- ineffassign
- revive
# - revive # TODO: enable by #16610
- staticcheck
- stylecheck
- unused
- unconvert # Remove unnecessary type conversions
# - stylecheck # TODO: enable by #16610
# - unused # TODO: enable by #16610
# - unconvert # Remove unnecessary type conversions TODO: enable by #16610
linters-settings: # please keep this alphabetized
goimports:
local-prefixes: go.etcd.io # Put imports beginning with prefix after 3rd-party packages.