Skip to content

Commit eef7d0f

Browse files
committed
fix: fix clang-tidy issues
1 parent 8466b89 commit eef7d0f

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

include/sdbus-c++/Awaitable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace sdbus {
126126
}
127127

128128
// Called when the coroutine is resumed. Returns the result or throws the exception.
129-
T await_resume() const
129+
[[nodiscard]] T await_resume() const
130130
{
131131
if (auto* exception = std::get_if<std::exception_ptr>(&data_->result); exception != nullptr)
132132
std::rethrow_exception(*exception);

tests/integrationtests/DBusAwaitableMethodsTests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <future>
3232
#include <map>
3333
#include <string>
34-
#include <type_traits>
3534
#include <utility>
3635

3736
#include <sdbus-c++/sdbus-c++.h>
@@ -40,7 +39,6 @@
4039

4140
#include "TestFixture.h"
4241
#include "TestProxy.h"
43-
#include "Defs.h"
4442

4543
using ::testing::Eq;
4644
using namespace std::chrono_literals;
@@ -82,14 +80,14 @@ struct Task {
8280
return {};
8381
}
8482

85-
void return_value(T v) { value = std::move(v); }
83+
void return_value(T val) { value = std::move(val); }
8684
void unhandled_exception() { exception = std::current_exception(); }
8785
};
8886

8987
std::coroutine_handle<promise_type> handle;
9088

9189
// Ctor and rule of 5 for proper handle management
92-
explicit Task(std::coroutine_handle<promise_type> h) : handle(h) {}
90+
explicit Task(std::coroutine_handle<promise_type> hnd) : handle(hnd) {}
9391
Task(Task&& other) noexcept : handle(std::exchange(other.handle, {})) {}
9492
Task& operator=(Task&& other) noexcept {
9593
if (this != &other) {
@@ -121,7 +119,7 @@ struct Task<void> {
121119
return Task{std::coroutine_handle<promise_type>::from_promise(*this)};
122120
}
123121

124-
std::suspend_always initial_suspend() noexcept { return {}; }
122+
std::suspend_always initial_suspend() noexcept { return {}; } // NOLINT(readability-convert-member-functions-to-static)
125123

126124
std::suspend_always final_suspend() noexcept
127125
{
@@ -142,7 +140,7 @@ struct Task<void> {
142140

143141
std::coroutine_handle<promise_type> handle;
144142

145-
explicit Task(std::coroutine_handle<promise_type> h) : handle(h) {}
143+
explicit Task(std::coroutine_handle<promise_type> hnd) : handle(hnd) {}
146144
Task(Task&& other) noexcept : handle(std::exchange(other.handle, {})) {}
147145
Task& operator=(Task&& other) noexcept {
148146
if (this != &other) {
@@ -156,8 +154,8 @@ struct Task<void> {
156154

157155
~Task() { if (handle) handle.destroy(); }
158156

159-
void resume() { if (handle && !handle.done()) handle.resume(); }
160-
void get() { handle.promise().future.get(); }
157+
void resume() { if (handle && !handle.done()) handle.resume(); } // NOLINT(readability-make-member-function-const)
158+
void get() { handle.promise().future.get(); } // NOLINT(readability-make-member-function-const)
161159
};
162160

163161
/*-------------------------------------*/
@@ -195,9 +193,11 @@ TYPED_TEST(AsyncSdbusTestObject, InvokesMethodWithLargeDataAsynchronouslyOnClien
195193
for (int32_t i = 0; i < 40'000; ++i)
196194
largeMap.emplace(i, "This is string nr. " + std::to_string(i+1));
197195

198-
auto task = [&largeMap, this]() -> Task<std::map<int32_t, std::string>> {
196+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) -- lambda closure has guaranteed lifetime
197+
auto lambda = [&largeMap, this]() -> Task<std::map<int32_t, std::string>> {
199198
co_return co_await this->m_proxy->doOperationWithLargeDataClientSideAsync(largeMap, sdbus::with_awaitable);
200-
}();
199+
};
200+
auto task = lambda();
201201

202202
task.resume();
203203

0 commit comments

Comments
 (0)