Skip to content

Commit

Permalink
Fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed May 1, 2024
1 parent bb7cafc commit 6b6ad92
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 0 additions & 2 deletions src/api/common/src/binance-common-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/api/common/src/exchangeprivateapi.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "exchangeprivateapi.hpp"

#include <algorithm>
#include <chrono>
#include <cstdint>
#include <iterator>
#include <limits>
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/api/exchanges/src/binanceprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
[]<bool flag = false>() { static_assert(flag, "no match"); }();
}
}
std::ranges::sort(orderVector);
Expand Down Expand Up @@ -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<string&>()), recentDeposit.amount(),
recentDeposit.timePoint());
return {std::move(depositEl["id"].get_ref<string&>()), recentDeposit.amount(), recentDeposit.timePoint()};
}

} // namespace cct::api
1 change: 0 additions & 1 deletion src/api/exchanges/src/binancepublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/api/exchanges/src/bithumbprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
[]<bool flag = false>() { static_assert(flag, "no match"); }();
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/api/exchanges/src/huobiprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/api/exchanges/src/krakenprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/api/exchanges/src/krakenpublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/api/exchanges/src/kucoinprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
[]<bool flag = false>() { static_assert(flag, "no match"); }();
}
}
std::ranges::sort(orderVector);
Expand Down
3 changes: 1 addition & 2 deletions src/api/exchanges/src/upbitprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
[]<bool flag = false>() { static_assert(flag, "no match"); }();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/objects/include/exchangename.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
1 change: 1 addition & 0 deletions src/objects/src/exchangeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/objects/src/marketorderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iterator>
#include <limits>
#include <numeric>
#include <optional>
Expand Down
4 changes: 2 additions & 2 deletions src/tech/include/toupperlower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/tech/test/stringhelpers_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <cstdint>
#include <limits>
#include <string_view>

#include "cct_string.hpp"

Expand Down

0 comments on commit 6b6ad92

Please sign in to comment.