diff options
9 files changed, 63 insertions, 61 deletions
diff --git a/.clang-tidy b/.clang-tidy index e7b899d7..5fe6d074 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -54,3 +54,5 @@ CheckOptions: - { key: readability-identifier-naming.EnumCase, value: CamelCase } - { key: readability-identifier-naming.StructCase, value: CamelCase } - { key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase } + - { key: readability-identifier-naming.StaticConstantCase, value: CamelCase } + - { key: readability-identifier-naming.StaticConstantPrefix, value: k } diff --git a/src/buildtool/execution_api/execution_service/ac_server.cpp b/src/buildtool/execution_api/execution_service/ac_server.cpp index 3da0bf1f..d0c1a74c 100644 --- a/src/buildtool/execution_api/execution_service/ac_server.cpp +++ b/src/buildtool/execution_api/execution_service/ac_server.cpp @@ -34,9 +34,9 @@ auto ActionCacheServiceImpl::GetActionResult( logger_.Emit(LogLevel::Trace, "GetActionResult: {}", action_digest->hash()); auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = "Could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + static constexpr auto kStr = "Could not acquire SharedLock"; + logger_.Emit(LogLevel::Error, kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } auto action_result = storage_.ActionCache().CachedResult(*action_digest); @@ -54,7 +54,7 @@ auto ActionCacheServiceImpl::UpdateActionResult( const ::bazel_re::UpdateActionResultRequest* /*request*/, ::bazel_re::ActionResult* /*response*/) -> ::grpc::Status { - static auto constexpr str = "UpdateActionResult not implemented"; - logger_.Emit(LogLevel::Error, str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static auto constexpr kStr = "UpdateActionResult not implemented"; + logger_.Emit(LogLevel::Error, kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 7d2bd48a..642347cc 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -54,9 +54,9 @@ auto BytestreamServiceImpl::Read( auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = "Could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + static constexpr auto kStr = "Could not acquire SharedLock"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } auto const path = @@ -125,9 +125,9 @@ auto BytestreamServiceImpl::Write( request.finish_write()); auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = "Could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + static constexpr auto kStr = "Could not acquire SharedLock"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } auto const tmp_dir = storage_config_.CreateTypedTmpDir("execution-service"); if (not tmp_dir) { @@ -166,7 +166,7 @@ auto BytestreamServiceImpl::QueryWriteStatus( const ::google::bytestream::QueryWriteStatusRequest* /*request*/, ::google::bytestream::QueryWriteStatusResponse* /*response*/) -> ::grpc::Status { - static constexpr auto str = "QueryWriteStatus not implemented"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static constexpr auto kStr = "QueryWriteStatus not implemented"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } diff --git a/src/buildtool/execution_api/execution_service/cas_server.cpp b/src/buildtool/execution_api/execution_service/cas_server.cpp index 6ca79348..f32b2754 100644 --- a/src/buildtool/execution_api/execution_service/cas_server.cpp +++ b/src/buildtool/execution_api/execution_service/cas_server.cpp @@ -55,10 +55,10 @@ auto CASServiceImpl::FindMissingBlobs( ::bazel_re::FindMissingBlobsResponse* response) -> ::grpc::Status { auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = + static constexpr auto kStr = "FindMissingBlobs: could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } for (auto const& x : request->blob_digests()) { auto const digest = ArtifactDigestFactory::FromBazel( @@ -92,10 +92,10 @@ auto CASServiceImpl::BatchUpdateBlobs( ::bazel_re::BatchUpdateBlobsResponse* response) -> ::grpc::Status { auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = + static constexpr auto kStr = "BatchUpdateBlobs: could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } auto const hash_type = storage_config_.hash_function.GetType(); for (auto const& x : request->requests()) { @@ -130,10 +130,10 @@ auto CASServiceImpl::BatchReadBlobs( ::bazel_re::BatchReadBlobsResponse* response) -> ::grpc::Status { auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = + static constexpr auto kStr = "BatchReadBlobs: Could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } for (auto const& x : request->digests()) { auto* r = response->add_responses(); @@ -173,9 +173,9 @@ auto CASServiceImpl::GetTree( const ::bazel_re::GetTreeRequest* /*request*/, ::grpc::ServerWriter<::bazel_re::GetTreeResponse>* /*writer*/) -> ::grpc::Status { - static constexpr auto str = "GetTree not implemented"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static constexpr auto kStr = "GetTree not implemented"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } auto CASServiceImpl::SplitBlob(::grpc::ServerContext* /*context*/, @@ -183,9 +183,9 @@ auto CASServiceImpl::SplitBlob(::grpc::ServerContext* /*context*/, ::bazel_re::SplitBlobResponse* response) -> ::grpc::Status { if (not request->has_blob_digest()) { - static constexpr auto str = "SplitBlob: no blob digest provided"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INVALID_ARGUMENT, str}; + static constexpr auto kStr = "SplitBlob: no blob digest provided"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::INVALID_ARGUMENT, kStr}; } auto const blob_digest = ArtifactDigestFactory::FromBazel( @@ -220,10 +220,10 @@ auto CASServiceImpl::SplitBlob(::grpc::ServerContext* /*context*/, // Acquire garbage collection lock. auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = + static constexpr auto kStr = "SplitBlob: could not acquire garbage collection lock"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } // Split blob into chunks. @@ -266,9 +266,9 @@ auto CASServiceImpl::SpliceBlob(::grpc::ServerContext* /*context*/, ::bazel_re::SpliceBlobResponse* response) -> ::grpc::Status { if (not request->has_blob_digest()) { - static constexpr auto str = "SpliceBlob: no blob digest provided"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INVALID_ARGUMENT, str}; + static constexpr auto kStr = "SpliceBlob: no blob digest provided"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::INVALID_ARGUMENT, kStr}; } auto const hash_type = storage_config_.hash_function.GetType(); @@ -302,10 +302,10 @@ auto CASServiceImpl::SpliceBlob(::grpc::ServerContext* /*context*/, // Acquire garbage collection lock. auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = + static constexpr auto kStr = "SpliceBlob: could not acquire garbage collection lock"; - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; + logger_.Emit(LogLevel::Error, "{}", kStr); + return ::grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } // Splice blob from chunks. diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index 6f77ba3f..1b416ec8 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -176,9 +176,9 @@ auto ExecutionServiceImpl::Execute( auto const lock = GarbageCollector::SharedLock(storage_config_); if (not lock) { - static constexpr auto str = "Could not acquire SharedLock"; - logger_.Emit(LogLevel::Error, "{}", str); - return grpc::Status{grpc::StatusCode::INTERNAL, str}; + static constexpr auto kStr = "Could not acquire SharedLock"; + logger_.Emit(LogLevel::Error, "{}", kStr); + return grpc::Status{grpc::StatusCode::INTERNAL, kStr}; } auto action = ToBazelAction(*action_digest, storage_); diff --git a/src/buildtool/execution_api/execution_service/operations_server.cpp b/src/buildtool/execution_api/execution_service/operations_server.cpp index 43997803..33fd61b4 100644 --- a/src/buildtool/execution_api/execution_service/operations_server.cpp +++ b/src/buildtool/execution_api/execution_service/operations_server.cpp @@ -46,25 +46,25 @@ auto OperationsServiceImpl::ListOperations( const ::google::longrunning::ListOperationsRequest* /*request*/, ::google::longrunning::ListOperationsResponse* /*response*/) -> ::grpc::Status { - static constexpr auto str = "ListOperations not implemented"; - logger_.Emit(LogLevel::Error, str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static constexpr auto kStr = "ListOperations not implemented"; + logger_.Emit(LogLevel::Error, kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } auto OperationsServiceImpl::DeleteOperation( ::grpc::ServerContext* /*context*/, const ::google::longrunning::DeleteOperationRequest* /*request*/, ::google::protobuf::Empty* /*response*/) -> ::grpc::Status { - static constexpr auto str = "DeleteOperation not implemented"; - logger_.Emit(LogLevel::Error, str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static constexpr auto kStr = "DeleteOperation not implemented"; + logger_.Emit(LogLevel::Error, kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } auto OperationsServiceImpl::CancelOperation( ::grpc::ServerContext* /*context*/, const ::google::longrunning::CancelOperationRequest* /*request*/, ::google::protobuf::Empty* /*response*/) -> ::grpc::Status { - static constexpr auto str = "CancelOperation not implemented"; - logger_.Emit(LogLevel::Error, str); - return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, str}; + static constexpr auto kStr = "CancelOperation not implemented"; + logger_.Emit(LogLevel::Error, kStr); + return ::grpc::Status{grpc::StatusCode::UNIMPLEMENTED, kStr}; } diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp index 9dc16592..529c4064 100644 --- a/src/buildtool/file_system/file_system_manager.hpp +++ b/src/buildtool/file_system/file_system_manager.hpp @@ -1166,10 +1166,10 @@ class FileSystemManager { std::filesystem::file_status const& status) noexcept -> bool { try { namespace fs = std::filesystem; - static constexpr auto exec_flags = fs::perms::owner_exec bitor + static constexpr auto kExecFlags = fs::perms::owner_exec bitor fs::perms::group_exec bitor fs::perms::others_exec; - auto exec_perms = status.permissions() bitand exec_flags; + auto exec_perms = status.permissions() bitand kExecFlags; return exec_perms != fs::perms::none; } catch (std::exception const& e) { Logger::Log(LogLevel::Error, diff --git a/src/buildtool/storage/large_object_cas.tpp b/src/buildtool/storage/large_object_cas.tpp index c2b08b45..bb7794bb 100644 --- a/src/buildtool/storage/large_object_cas.tpp +++ b/src/buildtool/storage/large_object_cas.tpp @@ -263,10 +263,10 @@ auto LargeObjectCAS<kDoGlobalUplink, kType>::LocalUplink( // Promoting the parts of the large entry: for (auto const& part : *parts) { - static constexpr bool is_executable = false; - static constexpr bool skip_sync = true; + static constexpr bool kIsExecutable = false; + static constexpr bool kSkipSync = true; if (not local_cas_.LocalUplinkBlob( - latest, part, is_executable, skip_sync)) { + latest, part, kIsExecutable, kSkipSync)) { return false; } } diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp index ab4d0715..b87c8db3 100644 --- a/test/buildtool/storage/large_object_cas.test.cpp +++ b/test/buildtool/storage/large_object_cas.test.cpp @@ -350,8 +350,8 @@ static void TestExternal(StorageConfig const& storage_config, // generation: REQUIRE(GarbageCollector::TriggerGarbageCollection(storage_config)); for (auto const& part : *pack_1) { - static constexpr bool is_executable = false; - REQUIRE(cas.BlobPath(part, is_executable)); + static constexpr bool kIsExecutable = false; + REQUIRE(cas.BlobPath(part, kIsExecutable)); } auto const youngest = ::Generation::Create(&storage_config); @@ -445,12 +445,12 @@ static void TestCompactification(StorageConfig const& storage_config, // For trees the size must be increased to exceed the internal // compactification threshold: - static constexpr auto ExceedThresholdSize = + static constexpr auto kExceedThresholdSize = kIsTree ? TestType::kLargeSize * 8 : TestType::kLargeSize; // Create a large object that is to be split during compactification: auto object_2 = TestType::Create( - cas, std::string(TestType::kLargeId) + "_2", ExceedThresholdSize); + cas, std::string(TestType::kLargeId) + "_2", kExceedThresholdSize); REQUIRE(object_2); auto& [digest_2, path_2] = *object_2; @@ -458,7 +458,7 @@ static void TestCompactification(StorageConfig const& storage_config, // may be present in the storage. To ensure compactification deals with // them properly, a "unique" file is created: auto invalid_object = TestType::Create( - cas, std::string(TestType::kLargeId) + "_3", ExceedThresholdSize); + cas, std::string(TestType::kLargeId) + "_3", kExceedThresholdSize); REQUIRE(invalid_object); auto& [invalid_digest, invalid_path] = *invalid_object; |