diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | src/buildtool/common/artifact.hpp | 10 | ||||
-rw-r--r-- | src/buildtool/execution_api/common/bytestream_utils.cpp | 4 | ||||
-rw-r--r-- | src/buildtool/execution_api/execution_service/bytestream_server.cpp | 2 | ||||
-rw-r--r-- | src/buildtool/execution_api/execution_service/execution_server.cpp | 20 | ||||
-rw-r--r-- | src/buildtool/execution_api/remote/bazel/bytestream_client.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/file_system/file_system_manager.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/file_system/git_context.cpp | 1 | ||||
-rw-r--r-- | src/buildtool/logging/logger.hpp | 12 | ||||
-rw-r--r-- | src/buildtool/storage/compactification_task.hpp | 8 | ||||
-rw-r--r-- | src/buildtool/system/system_command.hpp | 4 | ||||
-rw-r--r-- | src/other_tools/utils/curl_context.cpp | 5 | ||||
-rw-r--r-- | test/buildtool/build_engine/expression/linked_map.test.cpp | 3 | ||||
-rw-r--r-- | test/buildtool/execution_engine/traverser/traverser.test.cpp | 1 | ||||
-rw-r--r-- | test/buildtool/logging/logger.test.cpp | 2 |
15 files changed, 38 insertions, 43 deletions
diff --git a/.clang-tidy b/.clang-tidy index 25b3260d..7d34c5d9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,7 @@ WarningsAsErrors: >- clang-analyzer-*,-clang-analyzer-cplusplus.NewDeleteLeaks, clang-diagnostic-*,-clang-diagnostic-unused-command-line-argument, concurrency-*, -concurrency-mt-unsafe, + cppcoreguidelines-*,-cppcoreguidelines-avoid-const-or-ref-data-members,-cppcoreguidelines-rvalue-reference-param-not-moved, google-*, hicpp-*, misc-*,-misc-const-correctness,-misc-include-cleaner,-misc-use-anonymous-namespace,-misc-no-recursion, diff --git a/src/buildtool/common/artifact.hpp b/src/buildtool/common/artifact.hpp index 07c508c2..6fcde282 100644 --- a/src/buildtool/common/artifact.hpp +++ b/src/buildtool/common/artifact.hpp @@ -114,16 +114,6 @@ class Artifact { explicit Artifact(ArtifactIdentifier id) noexcept : id_{std::move(id)} {} - Artifact(Artifact const& other) noexcept - : id_{other.id_}, file_path_{other.file_path_}, repo_{other.repo_} { - object_info_ = other.object_info_; - } - - Artifact(Artifact&&) noexcept = default; - ~Artifact() noexcept = default; - auto operator=(Artifact const&) noexcept -> Artifact& = delete; - auto operator=(Artifact&&) noexcept -> Artifact& = default; - [[nodiscard]] auto Id() const& noexcept -> ArtifactIdentifier const& { return id_; } diff --git a/src/buildtool/execution_api/common/bytestream_utils.cpp b/src/buildtool/execution_api/common/bytestream_utils.cpp index f1b53f05..de66d58e 100644 --- a/src/buildtool/execution_api/common/bytestream_utils.cpp +++ b/src/buildtool/execution_api/common/bytestream_utils.cpp @@ -33,14 +33,14 @@ namespace { for (std::size_t length = 0; shift + length < request.size(); ++length) { if (request.at(shift + length) == '/') { - parts.emplace_back(request.data() + shift, length); + parts.emplace_back(&request.at(shift), length); shift += length + 1; length = 0; } } if (shift < request.size()) { - parts.emplace_back(request.data() + shift, request.size() - shift); + parts.emplace_back(&request.at(shift), request.size() - shift); } } catch (...) { return {}; diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 1740c1f1..7d2bd48a 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -138,7 +138,7 @@ auto BytestreamServiceImpl::Write( auto tmp = tmp_dir->GetPath() / write_digest->hash(); { std::ofstream stream{tmp, std::ios::binary}; - do { + do { // NOLINT(cppcoreguidelines-avoid-do-while) if (not stream.good()) { auto const str = fmt::format("Failed to write data for {}", write_digest->hash()); diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index cbf61edd..6f77ba3f 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -262,17 +262,17 @@ auto ExecutionServiceImpl::WaitExecution( return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str}; } logger_.Emit(LogLevel::Trace, "WaitExecution: {}", hash); - std::optional<::google::longrunning::Operation> op; - do { - op = op_cache_.Query(hash); - if (not op) { - auto const str = fmt::format( - "Executing action {} not found in internal cache.", hash); - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; - } + auto op = op_cache_.Query(hash); + while (op and not op->done()) { std::this_thread::sleep_for(std::chrono::seconds(1)); - } while (not op->done()); + op = op_cache_.Query(hash); + } + if (not op) { + auto const str = fmt::format( + "Executing action {} not found in internal cache.", hash); + logger_.Emit(LogLevel::Error, "{}", str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; + } writer->Write(*op); logger_.Emit(LogLevel::Trace, "Finished WaitExecution {}", hash); return ::grpc::Status::OK; diff --git a/src/buildtool/execution_api/remote/bazel/bytestream_client.hpp b/src/buildtool/execution_api/remote/bazel/bytestream_client.hpp index a67fd904..dca8d59a 100644 --- a/src/buildtool/execution_api/remote/bazel/bytestream_client.hpp +++ b/src/buildtool/execution_api/remote/bazel/bytestream_client.hpp @@ -117,8 +117,8 @@ class ByteStreamClient { request.set_resource_name(std::move(write_request).ToString()); request.mutable_data()->resize(ByteStreamUtils::kChunkSize, '\0'); - std::size_t pos{}; - do { + std::size_t pos = 0; + do { // NOLINT(cppcoreguidelines-avoid-do-while) auto const size = std::min(data.size() - pos, ByteStreamUtils::kChunkSize); request.mutable_data()->resize(size); diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp index ad3e4773..9dc16592 100644 --- a/src/buildtool/file_system/file_system_manager.hpp +++ b/src/buildtool/file_system/file_system_manager.hpp @@ -703,7 +703,7 @@ class FileSystemManager { std::ifstream file_reader(file.string(), std::ios::binary); if (file_reader.is_open()) { auto ssize = gsl::narrow<std::streamsize>(chunk.size()); - do { + while (file_reader.good()) { file_reader.read(chunk.data(), ssize); auto count = file_reader.gcount(); if (count == ssize) { @@ -713,7 +713,7 @@ class FileSystemManager { content += chunk.substr(0, gsl::narrow<std::size_t>(count)); } - } while (file_reader.good()); + } file_reader.close(); return content; } diff --git a/src/buildtool/file_system/git_context.cpp b/src/buildtool/file_system/git_context.cpp index 4fc613a3..f6f83c0d 100644 --- a/src/buildtool/file_system/git_context.cpp +++ b/src/buildtool/file_system/git_context.cpp @@ -24,6 +24,7 @@ extern "C" { GitContext::GitContext() noexcept { #ifndef BOOTSTRAP_BUILD_TOOL + // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer) initialized_ = git_libgit2_init() >= 0; if (not initialized_) { Logger::Log(LogLevel::Error, "initializing libgit2 failed"); diff --git a/src/buildtool/logging/logger.hpp b/src/buildtool/logging/logger.hpp index 32fd9fb0..f224edd8 100644 --- a/src/buildtool/logging/logger.hpp +++ b/src/buildtool/logging/logger.hpp @@ -154,11 +154,13 @@ class Logger { /// \brief Format message and forward to sinks. template <class... T_Args> - static void FormatAndForward(Logger const* logger, - std::vector<ILogSink::Ptr> const& sinks, - LogLevel level, - std::string const& msg, - T_Args&&... args) noexcept { + static void FormatAndForward( + Logger const* logger, + std::vector<ILogSink::Ptr> const& sinks, + LogLevel level, + std::string const& msg, + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) + T_Args&&... args) noexcept { if constexpr (sizeof...(T_Args) == 0) { // forward to sinks std::for_each(sinks.cbegin(), sinks.cend(), [&](auto& sink) { diff --git a/src/buildtool/storage/compactification_task.hpp b/src/buildtool/storage/compactification_task.hpp index e0f7e492..dee2ee2c 100644 --- a/src/buildtool/storage/compactification_task.hpp +++ b/src/buildtool/storage/compactification_task.hpp @@ -76,9 +76,11 @@ struct CompactificationTask final { CompactificationTask const& task) noexcept -> bool; template <typename... Args> -void CompactificationTask::Log(LogLevel level, - std::string const& message, - Args&&... args) const noexcept { +void CompactificationTask::Log( + LogLevel level, + std::string const& message, + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) + Args&&... args) const noexcept { if (not logger) { ::Logger::Log(LogLevel::Error, "Logger is missing."); return; diff --git a/src/buildtool/system/system_command.hpp b/src/buildtool/system/system_command.hpp index ade2f54b..909c047a 100644 --- a/src/buildtool/system/system_command.hpp +++ b/src/buildtool/system/system_command.hpp @@ -201,7 +201,7 @@ class SystemCommand { // wait for child to finish and obtain return value int status{}; std::optional<int> retval{std::nullopt}; - do { + while (not retval) { if (::waitpid(pid, &status, 0) == -1) { // this should never happen logger_.Emit(LogLevel::Error, @@ -221,7 +221,7 @@ class SystemCommand { LogLevel::Debug, "Child got killed by signal {}", sig); } // continue waitpid() in case we got STOPSIG from child - } while (not retval); + } return retval; } diff --git a/src/other_tools/utils/curl_context.cpp b/src/other_tools/utils/curl_context.cpp index 3e0b514e..7006d727 100644 --- a/src/other_tools/utils/curl_context.cpp +++ b/src/other_tools/utils/curl_context.cpp @@ -21,9 +21,8 @@ extern "C" { #include <curl/curl.h> } -CurlContext::CurlContext() noexcept { - // NOLINTNEXTLINE(hicpp-signed-bitwise) - initialized_ = curl_global_init(CURL_GLOBAL_DEFAULT) >= 0; +CurlContext::CurlContext() noexcept + : initialized_{curl_global_init(CURL_GLOBAL_DEFAULT) >= 0} { if (not initialized_) { Logger::Log(LogLevel::Error, "initializing libcurl failed"); } diff --git a/test/buildtool/build_engine/expression/linked_map.test.cpp b/test/buildtool/build_engine/expression/linked_map.test.cpp index f6c3bd58..1a8ceff5 100644 --- a/test/buildtool/build_engine/expression/linked_map.test.cpp +++ b/test/buildtool/build_engine/expression/linked_map.test.cpp @@ -95,9 +95,8 @@ TEST_CASE("Lookup and iteration", "[linked_map]") { class CopyCounter { public: CopyCounter() : count_{std::make_shared<std::size_t>()} {} - CopyCounter(CopyCounter const& other) { + CopyCounter(CopyCounter const& other) : count_{other.count_} { ++(*other.count_); - count_ = other.count_; } CopyCounter(CopyCounter&&) = default; ~CopyCounter() = default; diff --git a/test/buildtool/execution_engine/traverser/traverser.test.cpp b/test/buildtool/execution_engine/traverser/traverser.test.cpp index a6fb2c85..6bbafc03 100644 --- a/test/buildtool/execution_engine/traverser/traverser.test.cpp +++ b/test/buildtool/execution_engine/traverser/traverser.test.cpp @@ -156,6 +156,7 @@ class TestExecutor { TestBuildInfo* build_info_; template <typename Container> + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) [[nodiscard]] auto AllAvailable(Container&& c) const noexcept -> bool { return std::all_of(std::begin(c), std::end(c), [](auto node) { return node->TraversalState()->IsAvailable(); diff --git a/test/buildtool/logging/logger.test.cpp b/test/buildtool/logging/logger.test.cpp index e0abd13a..deee7477 100644 --- a/test/buildtool/logging/logger.test.cpp +++ b/test/buildtool/logging/logger.test.cpp @@ -61,7 +61,7 @@ class LogSinkTest : public ILogSink { return [] { return std::make_shared<LogSinkTest>(); }; } - LogSinkTest() noexcept { id_ = TestPrints::GetId(); } + LogSinkTest() noexcept : id_{TestPrints::GetId()} {} void Emit(Logger const* logger, LogLevel level, |