diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 08ba4e86..eced2690 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -15,5 +15,6 @@ jobs: - name: Run clang-format style check for C/C++ programs. uses: jidicula/clang-format-action@v4.11.0 with: + clang-format-version: '18' check-path: "src" fallback-style: "Google" 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/bithumbprivateapi.cpp b/src/api/exchanges/src/bithumbprivateapi.cpp index fa160726..356d5108 100644 --- a/src/api/exchanges/src/bithumbprivateapi.cpp +++ b/src/api/exchanges/src/bithumbprivateapi.cpp @@ -565,8 +565,7 @@ OrderVectorType QueryOrders(const OrdersConstraints& ordersConstraints, Exchange orders.emplace_back(std::move(id), matchedVolume, price, placedTime, placedTime, 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"); }(); } } } 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/api/exchanges/src/kucoinprivateapi.cpp b/src/api/exchanges/src/kucoinprivateapi.cpp index 92cba0ec..49bf9f6c 100644 --- a/src/api/exchanges/src/kucoinprivateapi.cpp +++ b/src/api/exchanges/src/kucoinprivateapi.cpp @@ -282,8 +282,7 @@ void FillOrders(const OrdersConstraints& ordersConstraints, CurlHandle& curlHand 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); diff --git a/src/api/exchanges/src/upbitprivateapi.cpp b/src/api/exchanges/src/upbitprivateapi.cpp index acd0f0e5..c00be65c 100644 --- a/src/api/exchanges/src/upbitprivateapi.cpp +++ b/src/api/exchanges/src/upbitprivateapi.cpp @@ -320,8 +320,7 @@ void FillOrders(const OrdersConstraints& ordersConstraints, CurlHandle& curlHand 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"); }(); } } } diff --git a/src/objects/include/exchangename.hpp b/src/objects/include/exchangename.hpp index b3ebf81c..f5af5024 100644 --- a/src/objects/include/exchangename.hpp +++ b/src/objects/include/exchangename.hpp @@ -64,8 +64,7 @@ class ExchangeName { private: static constexpr auto kMinExchangeNameLength = - std::ranges::min_element(kSupportedExchanges, [](auto lhs, auto rhs) { return lhs.size() < rhs.size(); }) - -> size(); + std::ranges::min_element(kSupportedExchanges, [](auto lhs, auto rhs) { return lhs.size() < rhs.size(); })->size(); string::size_type underscorePos() const { return _nameWithKey.find('_', kMinExchangeNameLength); } 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/include/toupperlower.hpp b/src/tech/include/toupperlower.hpp index 059be956..2bbe3df9 100644 --- a/src/tech/include/toupperlower.hpp +++ b/src/tech/include/toupperlower.hpp @@ -4,7 +4,7 @@ namespace cct { /// constexpr version of std::toupper with chars, as unfortunately for now (May 2021) std::toupper is not constexpr constexpr char toupper(char ch) noexcept { switch (ch) { - // clang-format off + // clang-format off case 'a': return 'A'; case 'b': return 'B'; case 'c': return 'C'; @@ -40,7 +40,7 @@ constexpr char toupper(char ch) noexcept { /// constexpr version of std::tolower with chars, as unfortunately for now (May 2021) std::tolower is not constexpr constexpr char tolower(char ch) noexcept { switch (ch) { - // clang-format off + // clang-format off case 'A': return 'a'; case 'B': return 'b'; case 'C': return 'c'; 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"