Skip to content

Commit

Permalink
style: Address some issues reported by sonarsource and remove unused …
Browse files Browse the repository at this point in the history
…includes in tests
  • Loading branch information
Tradias committed Nov 17, 2023
1 parent b7fa2b9 commit a19fec1
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/agrpc/detail/register_callback_rpc_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct RegisterCallbackRPCHandlerOperation
{
if (!rpc.is_done())
{
rpc.wait_for_done([ptr = ServerRPCPtr{ptr, &wait_for_done_deleter}](const detail::ErrorCode&) {});
rpc.wait_for_done([p = ServerRPCPtr{ptr, &wait_for_done_deleter}](const detail::ErrorCode&) {});
guard.release();
alloc_guard.release();
}
Expand Down
2 changes: 1 addition & 1 deletion src/agrpc/detail/server_rpc_with_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ template <class ServerRPC>
struct ServerRPCWithRequest
: detail::RPCRequest<typename ServerRPC::Request, detail::has_initial_request(ServerRPC::TYPE)>
{
ServerRPCWithRequest(const typename ServerRPC::executor_type& executor)
explicit ServerRPCWithRequest(const typename ServerRPC::executor_type& executor)
: rpc_(detail::ServerRPCContextBaseAccess::construct<ServerRPC>(executor))
{
}
Expand Down
4 changes: 2 additions & 2 deletions src/agrpc/register_awaitable_rpc_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ AGRPC_NAMESPACE_BEGIN()
* The rpc handler will be invoked for every incoming request of this gRPC method. It must take `ServerRPC&` as
* first argument and `ServerRPC::Request&` as second argument (only for unary and server-streaming rpcs). The ServerRPC
* is automatically cancelled at the end of the rpc handler if `finish()` was not called earlier. The return value of
* the rpc handler is be `co_spawn`ed in a manner similar to:
* the rpc handler is `co_spawn`ed in a manner similar to:
* `asio::co_spawn(asio::get_associated_executor(completion_handler, executor), rpc_handler())`, where
* `completion_handler` is obtained from `token` and `executor` the first argument passed to this function.
* `completion_handler` is created from `token` and `executor` the first argument passed to this function.
*
* This asynchronous operation runs forever unless it is cancelled, the rpc handler throws an exception or the server is
* shutdown
Expand Down
2 changes: 1 addition & 1 deletion src/agrpc/register_yield_rpc_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ AGRPC_NAMESPACE_BEGIN()
* The rpc handler will be invoked for every incoming request of this gRPC method. It must take `ServerRPC&` as
* first, `ServerRPC::Request&` as second (only for unary and server-streaming rpcs) and
* `asio::basic_yield_context<Executor>` as third argument. The Executor is obtained by calling
* `asio::get_associated_executor(completion_handler, executor)`, where `completion_handler` is obtained from `token`
* `asio::get_associated_executor(completion_handler, executor)`, where `completion_handler` is created from `token`
* and `executor` the first argument passed to this function. The ServerRPC is automatically cancelled at the end of the
* rpc handler if `finish()` was not called earlier.
*
Expand Down
6 changes: 3 additions & 3 deletions src/agrpc/server_rpc_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class ServerRPCPtr
decltype(auto) request() const noexcept { return (server_rpc_->request_); }

private:
template <class, class, class>
friend struct detail::RegisterCallbackRPCHandlerOperation;

using Pointer = detail::ServerRPCWithRequest<ServerRPCT>*;
using Deleter = void (*)(Pointer) noexcept;

template <class, class, class>
friend struct detail::RegisterCallbackRPCHandlerOperation;

ServerRPCPtr(Pointer server_rpc, Deleter deleter) noexcept : server_rpc_(server_rpc), deleter_(deleter) {}

auto* release() noexcept { return std::exchange(server_rpc_, nullptr); }
Expand Down
2 changes: 0 additions & 2 deletions test/src/test_alarm_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "test/v1/test.grpc.pb.h"
#include "utils/asio_utils.hpp"
#include "utils/doctest.hpp"
#include "utils/exception.hpp"
#include "utils/grpc_context_test.hpp"
#include "utils/time.hpp"
#include "utils/utility.hpp"
Expand Down
2 changes: 0 additions & 2 deletions test/src/test_asio_grpc_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <agrpc/client_rpc.hpp>
#include <agrpc/rpc.hpp>

#include <cstddef>

#ifdef AGRPC_ASIO_HAS_CO_AWAIT
TEST_CASE_TEMPLATE("awaitable server streaming", Stub, test::v1::Test::Stub, test::v1::Test::StubInterface)
{
Expand Down
5 changes: 0 additions & 5 deletions test/src/test_client_rpc_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "test/v1/test.grpc.pb.h"
#include "utils/asio_utils.hpp"
#include "utils/client_rpc_test.hpp"
#include "utils/delete_guard.hpp"
#include "utils/doctest.hpp"
#include "utils/exception.hpp"
#include "utils/inline_executor.hpp"
#include "utils/io_context_test.hpp"
#include "utils/protobuf.hpp"
#include "utils/rpc.hpp"
#include "utils/server_rpc.hpp"
#include "utils/time.hpp"
#include "utils/utility.hpp"
Expand Down
4 changes: 1 addition & 3 deletions test/src/test_generic_rpc_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "test/v1/test.grpc.pb.h"
#include "test/msg/message.pb.h"
#include "utils/asio_utils.hpp"
#include "utils/doctest.hpp"
#include "utils/grpc_generic_client_server_test.hpp"
#include "utils/protobuf.hpp"

#include <agrpc/rpc.hpp>

#include <cstddef>

TEST_CASE_FIXTURE(test::GrpcGenericClientServerTest, "yield_context generic unary")
{
test::spawn_and_run(
Expand Down
1 change: 0 additions & 1 deletion test/src/test_notify_when_done_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "utils/destruction_tracker.hpp"
#include "utils/doctest.hpp"
#include "utils/grpc_client_server_test.hpp"
#include "utils/grpc_context_test.hpp"
#include "utils/rpc.hpp"
#include "utils/server_shutdown_initiator.hpp"
#include "utils/test_server.hpp"
Expand Down
2 changes: 0 additions & 2 deletions test/src/test_repeatedly_request_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "utils/asio_utils.hpp"
#include "utils/doctest.hpp"
#include "utils/grpc_client_server_test.hpp"
#include "utils/grpc_context_test.hpp"
#include "utils/grpc_generic_client_server_test.hpp"
#include "utils/io_context_test.hpp"
#include "utils/protobuf.hpp"
Expand All @@ -28,7 +27,6 @@
#include <agrpc/wait.hpp>

#include <cstddef>
#include <optional>
#include <thread>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion test/src/test_run_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "utils/asio_utils.hpp"
#include "utils/doctest.hpp"
#include "utils/grpc_context_test.hpp"
#include "utils/manual_lifetime.hpp"
#include "utils/time.hpp"

#include <agrpc/run.hpp>
Expand Down
1 change: 0 additions & 1 deletion test/src/test_unifex_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <agrpc/asio_grpc.hpp>
#include <agrpc/register_sender_rpc_handler.hpp>

#include <cstddef>
#include <optional>
#include <thread>

Expand Down
2 changes: 0 additions & 2 deletions test/src/test_waiter_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <agrpc/alarm.hpp>
#include <agrpc/waiter.hpp>

#include <cstddef>

template <class Singature>
inline constexpr auto IMMEDIATE = 0;

Expand Down

0 comments on commit a19fec1

Please sign in to comment.