From 855231a7a0687c08d01a3b3176ef10ad830caf03 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Mon, 23 Sep 2024 14:33:22 -0400 Subject: [PATCH] Upgrade ClangFormat to v19.1.0 Signed-off-by: Juan Cruz Viotti --- .github/workflows/ci.yml | 2 +- src/bucket/bucket.cc | 7 +- .../sourcemeta/hydra/bucket_aws_sigv4.h | 26 +++--- .../include/sourcemeta/hydra/http_method.h | 5 +- .../include/sourcemeta/hydra/http_status.h | 5 +- src/httpclient/request.cc | 4 +- src/httpclient/stream_curl.cc | 28 +++---- src/httpserver/httpserver.cc | 8 +- .../include/sourcemeta/hydra/httpserver.h | 4 +- src/httpserver/response.cc | 4 +- src/httpserver/static.cc | 4 +- test/e2e/httpclient/request_1_1_test.cc | 4 +- test/e2e/httpserver/stub.cc | 82 +++++++++---------- 13 files changed, 94 insertions(+), 89 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c88ec24..8896dc71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: CXX: ${{ matrix.platform.cxx }} steps: - name: Install ClangFormat - run: pip install clang-format==18.1.0 + run: pip install clang-format==19.1.0 - name: Install dependencies (GNU/Linux) if: runner.os == 'linux' diff --git a/src/bucket/bucket.cc b/src/bucket/bucket.cc index 1624f1dd..31b01df3 100644 --- a/src/bucket/bucket.cc +++ b/src/bucket/bucket.cc @@ -140,9 +140,10 @@ auto Bucket::upsert_json(const std::string &key, return promise.get_future(); } -auto Bucket::fetch_or_upsert(const std::string &key, - std::function - callback) -> std::future { +auto Bucket::fetch_or_upsert( + const std::string &key, + std::function callback) + -> std::future { std::promise promise; auto maybe_response{this->fetch_json(key).get()}; if (maybe_response.has_value()) { diff --git a/src/bucket/include/sourcemeta/hydra/bucket_aws_sigv4.h b/src/bucket/include/sourcemeta/hydra/bucket_aws_sigv4.h index bc1c0db6..fdf1cd3b 100644 --- a/src/bucket/include/sourcemeta/hydra/bucket_aws_sigv4.h +++ b/src/bucket/include/sourcemeta/hydra/bucket_aws_sigv4.h @@ -29,13 +29,15 @@ aws_sigv4(const http::Method method, const sourcemeta::jsontoolkit::URI &url, const std::chrono::system_clock::time_point now) -> std::map; -auto SOURCEMETA_HYDRA_BUCKET_EXPORT -aws_sigv4_scope(std::string_view datastamp, std::string_view region, - std::ostream &output) -> void; +auto SOURCEMETA_HYDRA_BUCKET_EXPORT aws_sigv4_scope(std::string_view datastamp, + std::string_view region, + std::ostream &output) + -> void; -auto SOURCEMETA_HYDRA_BUCKET_EXPORT -aws_sigv4_key(std::string_view secret_key, std::string_view region, - std::string_view datastamp) -> std::string; +auto SOURCEMETA_HYDRA_BUCKET_EXPORT aws_sigv4_key(std::string_view secret_key, + std::string_view region, + std::string_view datastamp) + -> std::string; auto SOURCEMETA_HYDRA_BUCKET_EXPORT aws_sigv4_canonical(const http::Method method, std::string_view host, @@ -47,13 +49,13 @@ aws_sigv4_canonical(const http::Method method, std::string_view host, // MM: Two-digit month (01-12) // DD: Two-digit day (01-31) // Example: 20230913 (September 13, 2023) -auto SOURCEMETA_HYDRA_BUCKET_EXPORT -aws_sigv4_datastamp(const std::chrono::system_clock::time_point time, - std::ostream &output) -> void; +auto SOURCEMETA_HYDRA_BUCKET_EXPORT aws_sigv4_datastamp( + const std::chrono::system_clock::time_point time, std::ostream &output) + -> void; -auto SOURCEMETA_HYDRA_BUCKET_EXPORT -aws_sigv4_iso8601(const std::chrono::system_clock::time_point time, - std::ostream &output) -> void; +auto SOURCEMETA_HYDRA_BUCKET_EXPORT aws_sigv4_iso8601( + const std::chrono::system_clock::time_point time, std::ostream &output) + -> void; } // namespace sourcemeta::hydra diff --git a/src/http/include/sourcemeta/hydra/http_method.h b/src/http/include/sourcemeta/hydra/http_method.h index 82a4b91c..76641914 100644 --- a/src/http/include/sourcemeta/hydra/http_method.h +++ b/src/http/include/sourcemeta/hydra/http_method.h @@ -38,8 +38,9 @@ enum class Method { /// output << sourcemeta::hydra::http::Method::GET; /// assert(output.str() == "GET"); /// ``` -auto SOURCEMETA_HYDRA_HTTP_EXPORT -operator<<(std::ostream &stream, const Method method) -> std::ostream &; +auto SOURCEMETA_HYDRA_HTTP_EXPORT operator<<(std::ostream &stream, + const Method method) + -> std::ostream &; /// @ingroup http /// Construct a HTTP method from a string. Note that casing is not supported. diff --git a/src/http/include/sourcemeta/hydra/http_status.h b/src/http/include/sourcemeta/hydra/http_status.h index a1aac740..928cbae4 100644 --- a/src/http/include/sourcemeta/hydra/http_status.h +++ b/src/http/include/sourcemeta/hydra/http_status.h @@ -89,8 +89,9 @@ enum class Status : std::uint16_t { }; /// @ingroup http -auto SOURCEMETA_HYDRA_HTTP_EXPORT -operator<<(std::ostream &stream, const Status value) -> std::ostream &; +auto SOURCEMETA_HYDRA_HTTP_EXPORT operator<<(std::ostream &stream, + const Status value) + -> std::ostream &; } // namespace sourcemeta::hydra::http diff --git a/src/httpclient/request.cc b/src/httpclient/request.cc index 7e88727e..e324e735 100644 --- a/src/httpclient/request.cc +++ b/src/httpclient/request.cc @@ -40,8 +40,8 @@ auto ClientRequest::capture(std::initializer_list headers) auto ClientRequest::capture() -> void { this->capture_all_ = true; } -auto ClientRequest::header(std::string_view key, - std::string_view value) -> void { +auto ClientRequest::header(std::string_view key, std::string_view value) + -> void { this->stream.header(key, value); } diff --git a/src/httpclient/stream_curl.cc b/src/httpclient/stream_curl.cc index e25336d7..3c1780e7 100644 --- a/src/httpclient/stream_curl.cc +++ b/src/httpclient/stream_curl.cc @@ -42,10 +42,10 @@ inline auto handle_curl(CURLcode code) -> void { } } -auto callback_on_response_body(const void *const data, const std::size_t size, - const std::size_t count, - const sourcemeta::hydra::http::ClientStream - *const request) noexcept -> std::size_t { +auto callback_on_response_body( + const void *const data, const std::size_t size, const std::size_t count, + const sourcemeta::hydra::http::ClientStream *const request) noexcept + -> std::size_t { const std::size_t total_size{size * count}; if (request->internal->on_data) { try { @@ -61,10 +61,10 @@ auto callback_on_response_body(const void *const data, const std::size_t size, return total_size; } -auto callback_on_header(const void *const data, const std::size_t size, - const std::size_t count, - sourcemeta::hydra::http::ClientStream - *const request) noexcept -> std::size_t { +auto callback_on_header( + const void *const data, const std::size_t size, const std::size_t count, + sourcemeta::hydra::http::ClientStream *const request) noexcept + -> std::size_t { const std::size_t total_size{size * count}; const std::string_view line{static_cast(data), total_size}; const std::size_t colon{line.find(':')}; @@ -130,10 +130,10 @@ auto callback_on_header(const void *const data, const std::size_t size, return total_size; } -auto callback_on_request_body(char *buffer, const std::size_t size, - const std::size_t count, - sourcemeta::hydra::http::ClientStream - *const request) noexcept -> std::size_t { +auto callback_on_request_body( + char *buffer, const std::size_t size, const std::size_t count, + sourcemeta::hydra::http::ClientStream *const request) noexcept + -> std::size_t { assert(buffer); assert(request->internal->on_body); const std::size_t total_size{size * count}; @@ -242,8 +242,8 @@ auto ClientStream::on_body(BodyCallback callback) noexcept -> void { this->internal->on_body = std::move(callback); } -auto ClientStream::header(std::string_view key, - std::string_view value) -> void { +auto ClientStream::header(std::string_view key, std::string_view value) + -> void { std::stringstream stream; stream << key << ": " << value; const std::string result{stream.str()}; diff --git a/src/httpserver/httpserver.cc b/src/httpserver/httpserver.cc index 56d401b4..52daeb43 100644 --- a/src/httpserver/httpserver.cc +++ b/src/httpserver/httpserver.cc @@ -111,10 +111,10 @@ static auto wrap_route( logger << line.str(); } -static auto -default_handler(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto default_handler(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::NOT_IMPLEMENTED); response.end(); } diff --git a/src/httpserver/include/sourcemeta/hydra/httpserver.h b/src/httpserver/include/sourcemeta/hydra/httpserver.h index 15e5d4e2..129fe21c 100644 --- a/src/httpserver/include/sourcemeta/hydra/httpserver.h +++ b/src/httpserver/include/sourcemeta/hydra/httpserver.h @@ -80,8 +80,8 @@ class SOURCEMETA_HYDRA_HTTPSERVER_EXPORT Server { /// /// server.run(3000); /// ``` - auto route(const Method method, std::string &&path, - RouteCallback &&callback) -> void; + auto route(const Method method, std::string &&path, RouteCallback &&callback) + -> void; /// Set a handler that responds to HTTP requests that do not match any other /// registered routes. For example: diff --git a/src/httpserver/response.cc b/src/httpserver/response.cc index 3d94ec07..6b88b675 100644 --- a/src/httpserver/response.cc +++ b/src/httpserver/response.cc @@ -65,8 +65,8 @@ auto ServerResponse::status(const Status status_code) -> void { auto ServerResponse::status() const -> Status { return this->code; } -auto ServerResponse::header(std::string_view key, - std::string_view value) -> void { +auto ServerResponse::header(std::string_view key, std::string_view value) + -> void { this->headers.emplace(key, value); } diff --git a/src/httpserver/static.cc b/src/httpserver/static.cc index 21f57f7f..94b0fb30 100644 --- a/src/httpserver/static.cc +++ b/src/httpserver/static.cc @@ -9,8 +9,8 @@ namespace sourcemeta::hydra::http { auto serve_file(const std::filesystem::path &file_path, - const ServerRequest &request, - ServerResponse &response) -> void { + const ServerRequest &request, ServerResponse &response) + -> void { assert(request.method() == sourcemeta::hydra::http::Method::GET || request.method() == sourcemeta::hydra::http::Method::HEAD); diff --git a/test/e2e/httpclient/request_1_1_test.cc b/test/e2e/httpclient/request_1_1_test.cc index c508a875..94577e4a 100644 --- a/test/e2e/httpclient/request_1_1_test.cc +++ b/test/e2e/httpclient/request_1_1_test.cc @@ -13,8 +13,8 @@ #include "environment.h" -static auto -body(sourcemeta::hydra::http::ClientResponse &response) -> std::string { +static auto body(sourcemeta::hydra::http::ClientResponse &response) + -> std::string { std::ostringstream result; std::copy( std::istreambuf_iterator(response.body()), diff --git a/test/e2e/httpserver/stub.cc b/test/e2e/httpserver/stub.cc index 03325cc8..4a99f0c6 100644 --- a/test/e2e/httpserver/stub.cc +++ b/test/e2e/httpserver/stub.cc @@ -42,10 +42,10 @@ static auto on_throw(const sourcemeta::hydra::http::ServerLogger &, throw std::runtime_error("Crash!"); } -static auto -on_x_foo(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_x_foo(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::OK); if (request.header("x-foo").has_value()) { response.header("x-foo", request.header("x-foo").value()); @@ -54,10 +54,10 @@ on_x_foo(const sourcemeta::hydra::http::ServerLogger &, response.end(); } -static auto -on_query_foo(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_query_foo(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::OK); if (request.query("foo").has_value()) { response.header("x-foo", request.query("foo").value()); @@ -66,19 +66,19 @@ on_query_foo(const sourcemeta::hydra::http::ServerLogger &, response.end(); } -static auto -on_otherwise(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_otherwise(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::NOT_IMPLEMENTED); assert(response.status() == sourcemeta::hydra::http::Status::NOT_IMPLEMENTED); response.end(); } -static auto -on_parameters(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_parameters(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::OK); std::ostringstream result; result << request.parameter(0); @@ -89,10 +89,10 @@ on_parameters(const sourcemeta::hydra::http::ServerLogger &, response.end(result.str()); } -static auto -on_encodings(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_encodings(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { sourcemeta::jsontoolkit::JSON document{ sourcemeta::jsontoolkit::JSON::make_array()}; const auto accept_encoding{request.header_list("accept-encoding")}; @@ -107,19 +107,19 @@ on_encodings(const sourcemeta::hydra::http::ServerLogger &, response.end(document); } -static auto -on_force_gzip(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_force_gzip(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &, + sourcemeta::hydra::http::ServerResponse &response) + -> void { response.status(sourcemeta::hydra::http::Status::OK); response.encoding(sourcemeta::hydra::http::ServerContentEncoding::GZIP); response.end("I am compressed"); } -static auto -on_cache_me(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_cache_me(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { const auto timestamp{ sourcemeta::hydra::http::from_gmt("Wed, 21 Oct 2015 11:28:00 GMT")}; const auto checksum{"711d2f4adab4515e4036c48bf58eb975"}; @@ -153,10 +153,10 @@ on_etag_quoted(const sourcemeta::hydra::http::ServerLogger &, response.end("Cache me!"); } -static auto -on_schema(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_schema(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { // Purposely not very well formatted const auto schema = sourcemeta::jsontoolkit::parse(R"JSON({ "type": "string", "$schema": "https://json-schema.org/draft/2019-09/schema" @@ -184,10 +184,10 @@ static auto on_text(const sourcemeta::hydra::http::ServerLogger &, } } -static auto -on_static(const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &request, - sourcemeta::hydra::http::ServerResponse &response) -> void { +static auto on_static(const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &request, + sourcemeta::hydra::http::ServerResponse &response) + -> void { const std::filesystem::path file_path{STATIC_PATH + request.path().substr(7)}; if (!std::filesystem::exists(file_path)) { response.status(sourcemeta::hydra::http::Status::NOT_FOUND); @@ -198,11 +198,11 @@ on_static(const sourcemeta::hydra::http::ServerLogger &, sourcemeta::hydra::http::serve_file(file_path, request, response); } -static auto -on_error(std::exception_ptr error, - const sourcemeta::hydra::http::ServerLogger &, - const sourcemeta::hydra::http::ServerRequest &, - sourcemeta::hydra::http::ServerResponse &response) noexcept -> void { +static auto on_error(std::exception_ptr error, + const sourcemeta::hydra::http::ServerLogger &, + const sourcemeta::hydra::http::ServerRequest &, + sourcemeta::hydra::http::ServerResponse &response) noexcept + -> void { response.status(sourcemeta::hydra::http::Status::BAD_REQUEST); try { std::rethrow_exception(error);