From 7ef875b25f159cce7afb387c9a369b33c3744f86 Mon Sep 17 00:00:00 2001 From: Stephane Janel Date: Wed, 1 May 2024 09:53:25 +0200 Subject: [PATCH] Fix clang-tidy warnings --- src/api/common/src/binance-common-api.cpp | 2 -- src/api/common/src/exchangeprivateapi.cpp | 3 +-- src/api/exchanges/src/binanceprivateapi.cpp | 7 +++---- src/api/exchanges/src/binancepublicapi.cpp | 1 - src/api/exchanges/src/huobiprivateapi.cpp | 2 ++ src/api/exchanges/src/krakenprivateapi.cpp | 1 + src/api/exchanges/src/krakenpublicapi.cpp | 5 ++--- src/objects/src/exchangeconfig.cpp | 1 + src/objects/src/marketorderbook.cpp | 1 + src/tech/test/stringhelpers_test.cpp | 1 + 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/api/common/src/binance-common-api.cpp b/src/api/common/src/binance-common-api.cpp index 21b0436f..1cc78dd3 100644 --- a/src/api/common/src/binance-common-api.cpp +++ b/src/api/common/src/binance-common-api.cpp @@ -10,9 +10,7 @@ #include "cachedresult.hpp" #include "cct_json.hpp" #include "cct_log.hpp" -#include "cct_string.hpp" #include "curlhandle.hpp" -#include "curlpostdata.hpp" #include "currencycode.hpp" #include "currencycodeset.hpp" #include "currencyexchange.hpp" diff --git a/src/api/common/src/exchangeprivateapi.cpp b/src/api/common/src/exchangeprivateapi.cpp index e5317352..e7621c9d 100644 --- a/src/api/common/src/exchangeprivateapi.cpp +++ b/src/api/common/src/exchangeprivateapi.cpp @@ -1,7 +1,6 @@ #include "exchangeprivateapi.hpp" #include -#include #include #include #include @@ -391,7 +390,7 @@ MarketVector GetPossibleMarketsForDustThresholds(const BalancePortfolio &balance } private: - int weight(Market mk) const { + [[nodiscard]] int weight(Market mk) const { // not present is equivalent to a weight of 0 const auto it = _penaltyPerMarketMap.find(mk); return it == _penaltyPerMarketMap.end() ? 0 : it->second; diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index 7ed89c24..bec546ec 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -16,6 +16,7 @@ #include "apiquerytypeenum.hpp" #include "balanceoptions.hpp" #include "balanceportfolio.hpp" +#include "binance-common-api.hpp" #include "binancepublicapi.hpp" #include "cachedresult.hpp" #include "cct_exception.hpp" @@ -357,8 +358,7 @@ void FillOrders(const OrdersConstraints& ordersConstraints, const json& ordersAr orderVector.emplace_back(std::move(id), matchedVolume, price, placedTime, matchedTime, side); } else { // Note: below ugly template lambda can be replaced with 'static_assert(false);' in C++23 - []() { static_assert(flag, "no match"); } - (); + []() { static_assert(flag, "no match"); }(); } } std::ranges::sort(orderVector); @@ -820,8 +820,7 @@ ReceivedWithdrawInfo BinancePrivate::queryWithdrawDelivery(const InitiatedWithdr json& depositEl = depositStatus[closestDepositPos]; const RecentDeposit recentDeposit = recentDepositFromJsonEl(depositEl); - return ReceivedWithdrawInfo(std::move(depositEl["id"].get_ref()), recentDeposit.amount(), - recentDeposit.timePoint()); + return {std::move(depositEl["id"].get_ref()), recentDeposit.amount(), recentDeposit.timePoint()}; } } // namespace cct::api diff --git a/src/api/exchanges/src/binancepublicapi.cpp b/src/api/exchanges/src/binancepublicapi.cpp index 5437e980..12516dae 100644 --- a/src/api/exchanges/src/binancepublicapi.cpp +++ b/src/api/exchanges/src/binancepublicapi.cpp @@ -35,7 +35,6 @@ #include "market-vector.hpp" #include "market.hpp" #include "marketorderbook.hpp" -#include "monetary-amount-vector.hpp" #include "monetaryamount.hpp" #include "monetaryamountbycurrencyset.hpp" #include "order-book-line.hpp" diff --git a/src/api/exchanges/src/huobiprivateapi.cpp b/src/api/exchanges/src/huobiprivateapi.cpp index 7f0e457e..b06cc4e5 100644 --- a/src/api/exchanges/src/huobiprivateapi.cpp +++ b/src/api/exchanges/src/huobiprivateapi.cpp @@ -14,6 +14,7 @@ #include "balanceportfolio.hpp" #include "base64.hpp" #include "cachedresult.hpp" +#include "cct_cctype.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" @@ -38,6 +39,7 @@ #include "orderid.hpp" #include "ordersconstraints.hpp" #include "permanentcurloptions.hpp" +#include "query-retry-policy.hpp" #include "request-retry.hpp" #include "ssl_sha.hpp" #include "stringhelpers.hpp" diff --git a/src/api/exchanges/src/krakenprivateapi.cpp b/src/api/exchanges/src/krakenprivateapi.cpp index d3cceaee..b2ee3e7e 100644 --- a/src/api/exchanges/src/krakenprivateapi.cpp +++ b/src/api/exchanges/src/krakenprivateapi.cpp @@ -42,6 +42,7 @@ #include "orderid.hpp" #include "ordersconstraints.hpp" #include "permanentcurloptions.hpp" +#include "query-retry-policy.hpp" #include "request-retry.hpp" #include "ssl_sha.hpp" #include "stringhelpers.hpp" diff --git a/src/api/exchanges/src/krakenpublicapi.cpp b/src/api/exchanges/src/krakenpublicapi.cpp index 8acab996..0969ac5a 100644 --- a/src/api/exchanges/src/krakenpublicapi.cpp +++ b/src/api/exchanges/src/krakenpublicapi.cpp @@ -29,7 +29,6 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" -#include "monetaryamountbycurrencyset.hpp" #include "order-book-line.hpp" #include "permanentcurloptions.hpp" #include "public-trade-vector.hpp" @@ -319,9 +318,9 @@ Market GetKrakenMarketOrDefault(const CurrencyExchangeFlatSet& currencies, Marke const auto krakenBaseIt = currencies.find(mk.base()); const auto krakenQuoteIt = currencies.find(mk.quote()); if (krakenBaseIt != currencies.end() && krakenQuoteIt != currencies.end()) { - return Market(krakenBaseIt->altCode(), krakenQuoteIt->altCode()); + return {krakenBaseIt->altCode(), krakenQuoteIt->altCode()}; } - return Market{}; + return {}; } } // namespace diff --git a/src/objects/src/exchangeconfig.cpp b/src/objects/src/exchangeconfig.cpp index 8e01941b..61c1b4ab 100644 --- a/src/objects/src/exchangeconfig.cpp +++ b/src/objects/src/exchangeconfig.cpp @@ -13,6 +13,7 @@ #include "cct_string.hpp" #include "currencycodevector.hpp" #include "durationstring.hpp" +#include "http-config.hpp" #include "monetaryamount.hpp" #include "monetaryamountbycurrencyset.hpp" #include "permanentcurloptions.hpp" diff --git a/src/objects/src/marketorderbook.cpp b/src/objects/src/marketorderbook.cpp index 2d059fb3..89791843 100644 --- a/src/objects/src/marketorderbook.cpp +++ b/src/objects/src/marketorderbook.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tech/test/stringhelpers_test.cpp b/src/tech/test/stringhelpers_test.cpp index 2af5f876..15add270 100644 --- a/src/tech/test/stringhelpers_test.cpp +++ b/src/tech/test/stringhelpers_test.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "cct_string.hpp"