refactor: enable readability-container-contains clang-tidy rule

Replace the last few instances of `.count() != 0` and `.count() == 0` and `.count()` patterns with the more expressive C++20 `.contains()` method:

* `std::set<std::string>` in `getblocktemplate` RPC;
* `std::map<std::string, ...>` in `transaction_tests`;
* other bare `std::unordered_set` and `std::map` count calls.

With no remaining violations, enable the `readability-container-contains`
clang-tidy check to prevent future regressions.
This commit is contained in:
Lőrinc committed 2025-12-18 22:38:02 +01:00
1 parent fd9f1accbd
commit 1e94e562f7
5 files changed
+11 -10

No files matched your search

+5 -5
View File
@@ -124,7 +124,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
{
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
}
else if (wtx.value_map.count("from") && !wtx.value_map["from"].empty())
else if (wtx.value_map.contains("from") && !wtx.value_map["from"].empty())
{
// Online transaction
strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.value_map["from"]) + "<br>";
@@ -157,7 +157,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
//
// To
//
if (wtx.value_map.count("to") && !wtx.value_map["to"].empty())
if (wtx.value_map.contains("to") && !wtx.value_map["to"].empty())
{
// Online transaction
std::string strAddress = wtx.value_map["to"];
@@ -212,7 +212,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
if (toSelf && all_from_me)
continue;
if (!wtx.value_map.count("to") || wtx.value_map["to"].empty())
if (!wtx.value_map.contains("to") || wtx.value_map["to"].empty())
{
// Offline transaction
CTxDestination address;
@@ -273,9 +273,9 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
//
// Message
//
if (wtx.value_map.count("message") && !wtx.value_map["message"].empty())
if (wtx.value_map.contains("message") && !wtx.value_map["message"].empty())
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.value_map["message"], true) + "<br>";
if (wtx.value_map.count("comment") && !wtx.value_map["comment"].empty())
if (wtx.value_map.contains("comment") && !wtx.value_map["comment"].empty())
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.value_map["comment"], true) + "<br>";
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + rec->getTxHash() + "<br>";