From 56660492e4a669c8c0f02bd7f31ad31a3ef59883 Mon Sep 17 00:00:00 2001 From: Purnesh Dixit Date: Fri, 6 Sep 2024 23:13:30 +0530 Subject: [PATCH] vet: enforce revive linter (#7589) * enforce revive for issues that are already fixed --- scripts/revive.toml | 35 +++++++++++++++++++++++++++++++++++ scripts/vet.sh | 14 ++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 scripts/revive.toml diff --git a/scripts/revive.toml b/scripts/revive.toml new file mode 100644 index 000000000000..ea43fcdf34db --- /dev/null +++ b/scripts/revive.toml @@ -0,0 +1,35 @@ +# Enabled rules +[rule.blank-imports] +[rule.context-as-argument] +[rule.context-keys-type] +[rule.dot-imports] +[rule.errorf] +[rule.error-return] +[rule.error-strings] +[rule.error-naming] +[rule.increment-decrement] +[rule.range] +[rule.receiver-naming] +[rule.superfluous-else] +[rule.time-naming] +[rule.var-naming] +[rule.unexported-return] +[rule.unused-parameter] +[rule.unreachable-code] +[rule.var-declaration] +[rule.use-any] + +# Disabled rules +# https://github.com/grpc/grpc-go/issues/7444 to track TODO(s) +[rule.empty-block] + Disabled = true +[rule.import-shadowing] + Disabled = true +[rule.exported] + Disabled = true # TODO: Enable after existing issues are fixed +[rule.redefines-builtin-id] + Disabled = true # TODO: Enable after existing issues are fixed +[rule.package-comments] + Disabled = true # TODO: Enable after existing issues are fixed +[rule.indent-error-flow] + Disabled = true # TODO: Enable after existing issues are fixed diff --git a/scripts/vet.sh b/scripts/vet.sh index 67480f637b84..eefb31cfb92c 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -176,11 +176,13 @@ XXXXX PleaseIgnoreUnused' popd done -# Collection of revive linter analysis checks -REV_OUT="$(mktemp)" -revive -set_exit_status=1 -exclude "reflection/test/grpc_testing_not_regenerate/" -formatter plain ./... >"${REV_OUT}" || true - -# TODO: Remove `|| true` to unskip linter failures once existing issues are fixed. -(not grep -v "\.pb\.go:" "${REV_OUT}") || true +# Error for violation of enabled lint rules in config excluding generated code. +revive \ + -set_exit_status=1 \ + -exclude "reflection/test/grpc_testing_not_regenerate/" \ + -exclude "**/*.pb.go" \ + -formatter plain \ + -config "$(dirname "$0")/revive.toml" \ + ./... echo SUCCESS