Skip to content

Commit

Permalink
*: remove goimports(_fix)_pass and add lint_fix_pass
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <[email protected]>
  • Loading branch information
fuweid committed Sep 21, 2023
1 parent aa97484 commit 46df6ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 54 deletions.
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ fuzz:

verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
verify-shellws verify-proto-annotations verify-genproto verify-goimport verify-yamllint \
verify-shellws verify-proto-annotations verify-genproto verify-yamllint \
verify-govet-shadow
fix: fix-goimports fix-bom fix-lint fix-yamllint
fix: fix-bom fix-lint fix-yamllint
./scripts/fix.sh

.PHONY: verify-gofmt
Expand All @@ -91,7 +91,7 @@ verify-lint:

.PHONY: fix-lint
fix-lint:
golangci-lint run --config tools/.golangci.yaml --fix
PASSES="lint_fix" ./scripts/test.sh

.PHONY: verify-shellcheck
verify-shellcheck:
Expand Down Expand Up @@ -129,14 +129,6 @@ verify-proto-annotations:
verify-genproto:
PASSES="genproto" ./scripts/test.sh

.PHONY: verify-goimport
verify-goimport:
PASSES="goimport" ./scripts/test.sh

.PHONY: fix-goimports
fix-goimports:
./scripts/fix-goimports.sh

.PHONY: verify-yamllint
verify-yamllint:
yamllint --config-file tools/.yamllint .
Expand Down
28 changes: 0 additions & 28 deletions scripts/fix-goimports.sh

This file was deleted.

19 changes: 4 additions & 15 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ function lint_pass {
run_for_modules generic_checker run golangci-lint run --config "${ETCD_ROOT_DIR}/tools/.golangci.yaml"
}

function lint_fix_pass {
run_for_modules generic_checker run golangci-lint run --config "${ETCD_ROOT_DIR}/tools/.golangci.yaml" --fix
}

function revive_pass {
# TODO: etcdserverpb/raft_internal_stringer.go:15:1: should have a package comment
run_for_modules generic_checker run_go_tool "github.com/mgechev/revive" -config "${ETCD_ROOT_DIR}/tests/revive.toml" -exclude "vendor/..." -exclude "out/..."
Expand Down Expand Up @@ -671,21 +675,6 @@ function genproto_pass {
"${ETCD_ROOT_DIR}/scripts/verify_genproto.sh"
}

function goimport_for_module {
GOFILES=$(run go list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) || return 2
TESTGOFILES=$(run go list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) || return 2
cd "${ETCD_ROOT_DIR}/tools/mod"
FILESNEEDSFIX=$(echo "${GOFILES}" "${TESTGOFILES}" | grep -v '.gw.go' | grep -v '.pb.go' | xargs -n 100 go run golang.org/x/tools/cmd/goimports -l -local go.etcd.io)
if [ -n "$FILESNEEDSFIX" ]; then
log_error -e "the following files are not sync with 'goimports'. run 'make fix'\\n$FILESNEEDSFIX"
return 255
fi
}

function goimport_pass {
run_for_modules goimport_for_module
}

########### MAIN ###############################################################

function run_pass {
Expand Down

0 comments on commit 46df6ab

Please sign in to comment.