Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vet: enforce revive linter #7589

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions scripts/revive.toml
arvindbr8 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions scripts/vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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