From e8a70c6c7146bdf244dbe3e7e4ac03bbec47ef9b Mon Sep 17 00:00:00 2001 From: eshitachandwani <59800922+eshitachandwani@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:04:22 +0530 Subject: [PATCH] vet: add check to ensure terminating newline (#7645) --- Documentation/grpc-metadata.md | 2 +- examples/data/rbac/policy.json | 2 +- examples/features/name_resolving/README.md | 2 +- reflection/test/grpc_testing_not_regenerate/dynamic.proto | 2 +- scripts/vet.sh | 3 +++ testdata/x509/client_with_spiffe_openssl.cnf | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/grpc-metadata.md b/Documentation/grpc-metadata.md index f8d2b371ff98..488fc7ac3f02 100644 --- a/Documentation/grpc-metadata.md +++ b/Documentation/grpc-metadata.md @@ -241,4 +241,4 @@ available [here](../examples/features/metadata_interceptor/server/main.go). [Header]: https://godoc.org/google.golang.org/grpc#Header [Trailer]: https://godoc.org/google.golang.org/grpc#Trailer [CallOption]: https://godoc.org/google.golang.org/grpc#CallOption -[metadata]: https://godoc.org/google.golang.org/grpc/metadata \ No newline at end of file +[metadata]: https://godoc.org/google.golang.org/grpc/metadata diff --git a/examples/data/rbac/policy.json b/examples/data/rbac/policy.json index 97d6ae5a7d95..d1e2e958f8cf 100644 --- a/examples/data/rbac/policy.json +++ b/examples/data/rbac/policy.json @@ -27,4 +27,4 @@ } ], "deny_rules": [] -} \ No newline at end of file +} diff --git a/examples/features/name_resolving/README.md b/examples/features/name_resolving/README.md index 34456b9b1b0d..407b23fd1224 100644 --- a/examples/features/name_resolving/README.md +++ b/examples/features/name_resolving/README.md @@ -38,4 +38,4 @@ proper name resolver, this would fail. In the example it picks the `example` resolver that we installed. The `example` resolver can handle `resolver.example.grpc.io` correctly by returning the backend address. So even though the backend IP is not set when ClientConn is created, the connection will -be created to the correct backend. \ No newline at end of file +be created to the correct backend. diff --git a/reflection/test/grpc_testing_not_regenerate/dynamic.proto b/reflection/test/grpc_testing_not_regenerate/dynamic.proto index 6d263cae8473..6b6b0a72a589 100644 --- a/reflection/test/grpc_testing_not_regenerate/dynamic.proto +++ b/reflection/test/grpc_testing_not_regenerate/dynamic.proto @@ -30,4 +30,4 @@ message DynamicReq {} service DynamicService { // DynamicMessage1 is a test RPC for dynamically constructed protobufs. rpc DynamicMessage1(DynamicReq) returns (DynamicRes); -} \ No newline at end of file +} diff --git a/scripts/vet.sh b/scripts/vet.sh index 6431d5c613b7..3b8943b0fa65 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -70,6 +70,9 @@ not git grep "\(import \|^\s*\)\"google.golang.org/grpc/interop/grpc_testing" -- # - Ensure that no trailing spaces are found. not git grep '[[:blank:]]$' +# - Ensure that all files have a terminating newline. +git ls-files | not xargs -I {} sh -c '[ -n "$(tail -c 1 "{}" 2>/dev/null)" ] && echo "{}: No terminating new line found"' | fail_on_output + # - Ensure that no tabs are found in markdown files. not git grep $'\t' -- '*.md' diff --git a/testdata/x509/client_with_spiffe_openssl.cnf b/testdata/x509/client_with_spiffe_openssl.cnf index cf96f271d4a5..b7619830ce23 100644 --- a/testdata/x509/client_with_spiffe_openssl.cnf +++ b/testdata/x509/client_with_spiffe_openssl.cnf @@ -14,4 +14,4 @@ extendedKeyUsage = critical,clientAuth subjectAltName = @alt_names [alt_names] -URI = spiffe://foo.bar.com/client/workload/1 \ No newline at end of file +URI = spiffe://foo.bar.com/client/workload/1