diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs index 246072bff1305cc605e671fa3c766eb5d235acb7..543f6375df1b7bb6e03c26d411cb7f46c85f2c7a 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs @@ -219,4 +219,4 @@ namespace Grpc.Core.Internal.Tests } } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index e3ecc472826d9ac5d8ea1bf700d0b0bf9781ea43..1423145b9eec02d5c95cdd4f0d0c81a1b19c3ef1 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -456,4 +456,4 @@ namespace Grpc.Core.Internal streamingCallFinishedTcs.SetResult(null); } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs index 92f8d77e85d5cfe2c362bfc56462de2d902082e8..13d75a826b7ee72a5d227caa4c26e8308702c91c 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallBase.cs @@ -356,4 +356,4 @@ namespace Grpc.Core.Internal FireCompletion(origCompletionDelegate, msg, null); } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs index 0c805097f92feae6bc1f1d4d6dfce05f0f5f3fc4..36f2fed82c4e3032ca1db943dca32f6bc372a38d 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCallServer.cs @@ -215,4 +215,4 @@ namespace Grpc.Core.Internal finishedServersideTcs.SetResult(null); } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs b/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs index c88cae98fe75c326fbe9f4e898bcd7eaae3939c2..7e86fddb4d89ef583b49babf78da6f994ae180c0 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCompletion.cs @@ -91,4 +91,4 @@ namespace Grpc.Core.Internal tcs.SetException(error); } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs index 3a96414bea26ce24cf0878a4857e7503c5edf440..150e2115b31fb1a9fec57e7816559f9a82ea4287 100644 --- a/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/BatchContextSafeHandle.cs @@ -263,4 +263,4 @@ namespace Grpc.Core.Internal } } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs index 69dbdfea5e77fe7cabeab6fd59c23d676ea681e3..bbd8001492c1fcb510af948525622cef64276118 100644 --- a/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CallSafeHandle.cs @@ -273,4 +273,4 @@ namespace Grpc.Core.Internal return buffered ? 0 : GRPC_WRITE_BUFFER_HINT; } } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs index 29db85d7aae3e4eb88f72075bc4d64a11e4dcb7a..bde74945fbf691828fff12e80d7c434610747f43 100644 --- a/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.Core/Properties/AssemblyInfo.cs @@ -18,4 +18,4 @@ using System.Runtime.CompilerServices; "71394ee9672dfe5b55ea0f95dfd5a7f77d22c962ccf51320d3")] #else [assembly: InternalsVisibleTo("Grpc.Core.Tests")] -#endif \ No newline at end of file +#endif diff --git a/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs b/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs index d90f21c2e1cb30b7a3fe2e01297fb423cfa4a998..c7e1547144473929a9bb4597857313da2b3a2f60 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs +++ b/src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs @@ -93,4 +93,4 @@ namespace Grpc.HealthCheck.Tests // TODO(jtattermusch): add test with timeout once timeouts are supported } -} \ No newline at end of file +} diff --git a/src/csharp/Grpc.HealthCheck/Properties/AssemblyInfo.cs b/src/csharp/Grpc.HealthCheck/Properties/AssemblyInfo.cs index 41a54a98bc81a4ead5bd256994249786676d7f7e..4d7b33c669ccc85ab099a2757fb5ffbac64aa3c9 100644 --- a/src/csharp/Grpc.HealthCheck/Properties/AssemblyInfo.cs +++ b/src/csharp/Grpc.HealthCheck/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Runtime.CompilerServices; [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("Google Inc. All rights reserved.")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] \ No newline at end of file +[assembly: AssemblyCulture("")] diff --git a/src/node/test/echo_service.proto b/src/node/test/echo_service.proto index b2c7e3dc23676c8fb07891d0851528e84b921f2e..fc941a290442160c10c7b9f2b0ae4afe30cc1eff 100644 --- a/src/node/test/echo_service.proto +++ b/src/node/test/echo_service.proto @@ -36,4 +36,4 @@ message EchoMessage { service EchoService { rpc Echo (EchoMessage) returns (EchoMessage); -} \ No newline at end of file +} diff --git a/src/node/test/test_messages.proto b/src/node/test/test_messages.proto index 685e9482bd23dc2128a84130430e9c3741cdd351..1b611b82a7e7f539d4c331bf31bb1b3bde1eee45 100644 --- a/src/node/test/test_messages.proto +++ b/src/node/test/test_messages.proto @@ -35,4 +35,4 @@ message LongValues { sint64 sint_64 = 3; fixed64 fixed_64 = 4; sfixed64 sfixed_64 = 5; -} \ No newline at end of file +} diff --git a/src/node/test/test_service.proto b/src/node/test/test_service.proto index 564169829c39dc0f49bb0fc01f0c974165e97e1c..c86ce51d910383216e1ceb0193ad76e99f30612d 100644 --- a/src/node/test/test_service.proto +++ b/src/node/test/test_service.proto @@ -49,4 +49,4 @@ service TestService { rpc BidiStream (stream Request) returns (stream Response) { } -} \ No newline at end of file +} diff --git a/src/proto/grpc/health/v1alpha/health.proto b/src/proto/grpc/health/v1alpha/health.proto index 28786c4427da1fd2958eb8010d15f94db14ba1b5..e6214c569106e33efa223944a1b6edb692d2be2b 100644 --- a/src/proto/grpc/health/v1alpha/health.proto +++ b/src/proto/grpc/health/v1alpha/health.proto @@ -48,4 +48,4 @@ message HealthCheckResponse { service Health { rpc Check(HealthCheckRequest) returns (HealthCheckResponse); -} \ No newline at end of file +} diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index 3e2317c6d460f067c88cbd53a1990fbaea9083cf..f270cd09875e9998ae8b3b5f01eddd1079e9b2eb 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -599,4 +599,4 @@ std::unique_ptr<Client> CreateGenericAsyncStreamingClient( } } // namespace testing -} // namespace grpc \ No newline at end of file +} // namespace grpc diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 1045915b8327a95c2f4938dcbef3d808c19763f6..92fbf240ce2d2fe6028dd3b8493fe62f1fb6ddea 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -172,4 +172,4 @@ std::unique_ptr<Client> CreateSynchronousStreamingClient( } } // namespace testing -} // namespace grpc \ No newline at end of file +} // namespace grpc diff --git a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc index 7a1275054a6747e10769547413e6a1832a6edb87..2b2e1c820f5c63cb1249a9244d1993480198fffd 100644 --- a/test/cpp/qps/generic_async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/generic_async_streaming_ping_pong_test.cc @@ -79,4 +79,4 @@ int main(int argc, char** argv) { grpc::testing::RunGenericAsyncStreamingPingPong(); return 0; -} \ No newline at end of file +} diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index c70db188d9c93b847f2c796554fc060a32b3b6b0..eb0a7a5f4e6b82e97bd5a88cdeba4ba3c78dc676 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -184,4 +184,4 @@ int main(int argc, char** argv) { grpc::testing::QpsDriver(); return 0; -} \ No newline at end of file +} diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index e7714c0bb30f75b3dc442537aa86daaa8daee44a..bed867e1a4a86357a7bf1ecd8dadd5bf420aae45 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -239,4 +239,4 @@ QpsWorker::QpsWorker(int driver_port) { QpsWorker::~QpsWorker() {} } // namespace testing -} // namespace grpc \ No newline at end of file +} // namespace grpc diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 1ae88d7323e9e7a8c7adbc5f427e45bd93ebc1ef..d530dac86b3da27adafe43e64c99ebe793232385 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -397,4 +397,4 @@ std::unique_ptr<Server> CreateAsyncGenericServer(const ServerConfig &config) { } } // namespace testing -} // namespace grpc \ No newline at end of file +} // namespace grpc diff --git a/test/cpp/util/subprocess.cc b/test/cpp/util/subprocess.cc index d758f629acc85704790f1f7ff49f05b519ff6076..c31802b9a3bd2d9a4abc77d54580e1762f235cb4 100644 --- a/test/cpp/util/subprocess.cc +++ b/test/cpp/util/subprocess.cc @@ -56,4 +56,4 @@ int SubProcess::Join() { return gpr_subprocess_join(subprocess_); } void SubProcess::Interrupt() { gpr_subprocess_interrupt(subprocess_); } -} // namespace grpc \ No newline at end of file +} // namespace grpc diff --git a/tools/distrib/check_trailing_newlines.sh b/tools/distrib/check_trailing_newlines.sh new file mode 100755 index 0000000000000000000000000000000000000000..0be21f0cfffb0583928cb14c34888c7f526d2de5 --- /dev/null +++ b/tools/distrib/check_trailing_newlines.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# change to root directory +cd $(dirname $0)/../.. + +function find_without_newline() { + find . -type f -not -path './third_party/*' -and \( \ + -name '*.c' \ + -or -name '*.cc' \ + -or -name '*.proto' \ + -or -name '*.rb' \ + -or -name '*.py' \ + -or -name '*.cs' \ + -or -name '*.sh' \) -print0 \ + | while IFS= read -r -d '' f; do + if [[ ! -z $f ]]; then + if [[ $(tail -c 1 "$f") != $NEWLINE ]]; then + echo "Error: file '$f' is missing a trailing newline character." + if $2; then # fix + sed -i -e '$a\' $f + echo 'Fixed!' + fi + fi + fi + done +} + +if [[ $# == 1 && $1 == '--fix' ]]; then + ERRORS=$(find_without_newline true) +else + ERRORS=$(find_without_newline false) +fi + +if [[ "$ERRORS" != '' ]]; then + echo "$ERRORS" + if ! $FIX; then + exit 1 + fi +fi diff --git a/tools/run_tests/check_sources_and_headers.py b/tools/run_tests/check_sources_and_headers.py index cee32888dc455851617ad72832d2ded1c8803f7f..6f4c5a8657c3f720a60251deee02a512a6a75b71 100755 --- a/tools/run_tests/check_sources_and_headers.py +++ b/tools/run_tests/check_sources_and_headers.py @@ -80,4 +80,4 @@ for target in js: target['name'], fn, m.group(1))) errors += 1 -assert errors == 0 \ No newline at end of file +assert errors == 0 diff --git a/tools/run_tests/run_sanity.sh b/tools/run_tests/run_sanity.sh index 690332daae0a14db8e87d7135ddc144b8dd327ad..467f06edd750591eba0295804eb74c0e26e4cda0 100755 --- a/tools/run_tests/run_sanity.sh +++ b/tools/run_tests/run_sanity.sh @@ -60,4 +60,4 @@ fi ./tools/buildgen/generate_projects.sh ./tools/distrib/check_copyright.py ./tools/distrib/clang_format_code.sh - +./tools/distrib/check_trailing_newlines.sh