Skip to content

Commit f12d180

Browse files
committed
fixed more liting errors
1 parent 80f6d01 commit f12d180

File tree

8 files changed

+41
-35
lines changed

8 files changed

+41
-35
lines changed

lint/clang-tidy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ -z "$target_source" ]; then
5858
shopt -s globstar
5959

6060
pushd "$PROJECT_ROOT" > /dev/null
61-
for f in **/*.h **/*.cpp; do
61+
for f in include/**/*.h src/**/*.cpp; do
6262
if [[ ! ("$f" =~ "build/") ]]; then
6363
echo
6464
echo "Checking file '$f'"

src/communication/RpcClient.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ using uprotocol::v1::UStatus;
2424
using ListenHandle = uprotocol::transport::UTransport::ListenHandle;
2525

2626
struct PendingRequest {
27-
private:
2827
std::chrono::steady_clock::time_point when_expire;
2928
ListenHandle response_listener;
3029
std::function<void(UStatus)> expire;
@@ -69,7 +68,7 @@ struct RpcClient::ExpireService {
6968

7069
void enqueue(std::chrono::steady_clock::time_point when_expire,
7170
transport::UTransport::ListenHandle&& response_listener,
72-
std::function<void(v1::UStatus)> expire) {
71+
std::function<void(v1::UStatus)> expire) const {
7372
detail::PendingRequest pending;
7473
pending.when_expire = when_expire;
7574
pending.response_listener = std::move(response_listener);
@@ -247,17 +246,19 @@ RpcClient::InvokeFuture::InvokeFuture(std::future<MessageOrStatus>&& future,
247246
namespace {
248247
namespace detail {
249248

250-
using namespace uprotocol;
251-
using namespace std::chrono_literals;
249+
using uprotocol::v1::UStatus;
250+
using uprotocol::v1::UCode;
251+
// using namespace std::chrono_literals;
252+
using ListenHandle = uprotocol::transport::UTransport::ListenHandle;
252253

253254
auto PendingRequest::operator>(const PendingRequest& other) const {
254255
return when_expire > other.when_expire;
255256
}
256257

257258
ScrubablePendingQueue::~ScrubablePendingQueue() {
258-
const v1::UStatus cancel_reason = []() {
259-
v1::UStatus reason;
260-
reason.set_code(v1::UCode::INTERNAL);
259+
const UStatus cancel_reason = []() {
260+
UStatus reason;
261+
reason.set_code(UCode::INTERNAL);
261262
reason.set_message(
262263
"ERROR: ExpireWorker has shut down while requests are still "
263264
"pending. This should never occur and likely indicates that an "
@@ -273,7 +274,7 @@ ScrubablePendingQueue::~ScrubablePendingQueue() {
273274
auto ScrubablePendingQueue::scrub(size_t instance_id) {
274275
// Collect all the expire lambdas so they can be called without the
275276
// lock held.
276-
std::vector<std::function<void(v1::UStatus)>> all_expired;
277+
std::vector<std::function<void(UStatus)>> all_expired;
277278

278279
c.erase(
279280
std::remove_if(c.begin(), c.end(),
@@ -286,7 +287,7 @@ auto ScrubablePendingQueue::scrub(size_t instance_id) {
286287
}),
287288
c.end());
288289

289-
// TODO - is there a better way to shrink the internal container?
290+
// TODO(missing_author) - is there a better way to shrink the internal container?
290291
// Maybe instead we should enforce a capacity limit
291292
constexpr size_t CAPACITY_SHRINK_THRESHOLD = 16;
292293
if ((c.capacity() > CAPACITY_SHRINK_THRESHOLD) &&
@@ -307,29 +308,29 @@ ExpireWorker::ExpireWorker() {
307308
ExpireWorker::~ExpireWorker() {
308309
stop_ = true;
309310
{
310-
std::lock_guard lock(pending_mtx_);
311+
std::lock_guard const lock(pending_mtx_);
311312
wake_worker_.notify_one();
312313
}
313314
worker_.join();
314315
}
315316

316317
void ExpireWorker::enqueue(PendingRequest&& pending) {
317-
std::lock_guard lock(pending_mtx_);
318+
std::lock_guard const lock(pending_mtx_);
318319
pending_.emplace(std::move(pending));
319320
wake_worker_.notify_one();
320321
}
321322

322323
void ExpireWorker::scrub(size_t instance_id) {
323-
std::vector<std::function<void(v1::UStatus)>> all_expired;
324+
std::vector<std::function<void(UStatus)>> all_expired;
324325
{
325-
std::lock_guard lock(pending_mtx_);
326+
std::lock_guard const lock(pending_mtx_);
326327
all_expired = pending_.scrub(instance_id);
327328
wake_worker_.notify_one();
328329
}
329330

330-
static const v1::UStatus cancel_reason = []() {
331-
v1::UStatus reason;
332-
reason.set_code(v1::UCode::CANCELLED);
331+
static const UStatus cancel_reason = []() {
332+
UStatus reason;
333+
reason.set_code(UCode::CANCELLED);
333334
reason.set_message("RpcClient for this request was discarded");
334335
return reason;
335336
}();
@@ -345,8 +346,8 @@ void ExpireWorker::doWork() {
345346
std::optional<decltype(PendingRequest::expire)> maybe_expire;
346347

347348
{
348-
transport::UTransport::ListenHandle expired_handle;
349-
std::lock_guard lock(pending_mtx_);
349+
ListenHandle expired_handle;
350+
std::lock_guard const lock(pending_mtx_);
350351
if (!pending_.empty()) {
351352
const auto when_expire = pending_.top().when_expire;
352353
if (when_expire <= now) {
@@ -361,9 +362,9 @@ void ExpireWorker::doWork() {
361362
if (maybe_expire) {
362363
auto& expire = *maybe_expire;
363364

364-
static const v1::UStatus expire_reason = []() {
365-
v1::UStatus reason;
366-
reason.set_code(v1::UCode::DEADLINE_EXCEEDED);
365+
static const UStatus expire_reason = []() {
366+
UStatus reason;
367+
reason.set_code(UCode::DEADLINE_EXCEEDED);
367368
reason.set_message("Request expired before response received");
368369
return reason;
369370
}();

src/communication/RpcServer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RpcServer::ServerOrStatus RpcServer::create(
4343
v1::UStatus status;
4444
status.set_code(v1::UCode::INVALID_ARGUMENT);
4545
status.set_message("Invalid rpc URI");
46-
return uprotocol::utils::Unexpected(status);
46+
return ServerOrStatus(uprotocol::utils::Unexpected(status));
4747
}
4848

4949
// Validate the payload format, if provided.
@@ -53,7 +53,7 @@ RpcServer::ServerOrStatus RpcServer::create(
5353
v1::UStatus status;
5454
status.set_code(v1::UCode::OUT_OF_RANGE);
5555
status.set_message("Invalid payload format");
56-
return uprotocol::utils::Unexpected(status);
56+
return ServerOrStatus(uprotocol::utils::Unexpected(status));
5757
}
5858
}
5959

@@ -67,10 +67,10 @@ RpcServer::ServerOrStatus RpcServer::create(
6767
auto status = server->connect(method_name, std::move(callback));
6868
if (status.code() == v1::UCode::OK) {
6969
// If connection is successful, return the server instance.
70-
return server;
70+
return ServerOrStatus(server);
7171
} else {
7272
// If connection fails, return the error status.
73-
return uprotocol::utils::Unexpected(std::move(status));
73+
return ServerOrStatus(uprotocol::utils::Unexpected(std::move(status)));
7474
}
7575
}
7676

src/communication/Subscriber.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ namespace uri_validator = uprotocol::datamodel::validator::uri;
3737
auto handle = transport->registerListener(std::move(callback), topic);
3838

3939
if (!handle) {
40-
return uprotocol::utils::Unexpected(handle.error());
40+
return SubscriberOrStatus(uprotocol::utils::Unexpected(handle.error()));
4141
}
4242

43-
return std::make_unique<Subscriber>(
43+
return SubscriberOrStatus(std::make_unique<Subscriber>(
4444
std::forward<std::shared_ptr<transport::UTransport>>(transport),
45-
std::forward<ListenHandle&&>(std::move(handle).value()));
45+
std::forward<ListenHandle&&>(std::move(handle).value())));
4646
}
4747

4848
Subscriber::Subscriber(std::shared_ptr<transport::UTransport> transport,

src/datamodel/serializer/UUri.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
namespace uprotocol::datamodel::serializer::uri {
1919

2020
std::string AsString::serialize(const v1::UUri& uri) {
21-
using namespace uprotocol::datamodel::validator::uri;
21+
using uprotocol::datamodel::validator::uri::isValidFilter;
22+
using uprotocol::datamodel::validator::uri::InvalidUUri;
23+
using uprotocol::datamodel::validator::uri::isLocal;
24+
2225
// isValidFilter is the most permissive of the validators
2326
auto [valid, reason] = isValidFilter(uri);
2427
if (!valid) {

src/datamodel/validator/UMessage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
namespace uprotocol::datamodel::validator::message {
2020

21-
using namespace uprotocol::v1;
22-
using namespace uprotocol::datamodel::validator;
21+
using uprotocol::v1::UPRIORITY_CS4;
22+
// using uprotocol::datamodel::validator;
2323

2424
std::string_view message(Reason reason) {
2525
switch (reason) {

src/datamodel/validator/UUri.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ namespace {
1515

1616
constexpr size_t AUTHORITY_SPEC_MAX_LENGTH = 128;
1717

18-
using namespace uprotocol::datamodel::validator::uri;
18+
using uprotocol::datamodel::validator::uri::ValidationResult;
19+
using uprotocol::datamodel::validator::uri::Reason;
20+
1921
ValidationResult uriCommonValidChecks(const uprotocol::v1::UUri& uuri) {
2022
if (uuri.ue_version_major() == 0) {
2123
return {false, Reason::RESERVED_VERSION};

src/transport/UTransport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ UTransport::HandleOrStatus UTransport::registerListener(
8989
std::move(callable), source_filter, std::move(sink_filter));
9090

9191
if (status.code() == v1::UCode::OK) {
92-
return std::move(handle);
92+
return HandleOrStatus(std::move(handle));
9393
}
94-
return utils::Unexpected(std::move(status));
94+
return HandleOrStatus(utils::Unexpected(std::move(status)));
9595
}
9696

9797
// NOTE: deprecated

0 commit comments

Comments
 (0)