Skip to content

Commit

Permalink
vet: enforce revive linter (#7589)
Browse files Browse the repository at this point in the history
* enforce revive for issues that are already fixed
  • Loading branch information
purnesh42H authored Sep 6, 2024
1 parent c6ad07f commit 5666049
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
35 changes: 35 additions & 0 deletions scripts/revive.toml
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

0 comments on commit 5666049

Please sign in to comment.