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 Mar 7, 2024
1 parent 5ed3483 commit 8092696
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/api/common/include/exchangepublicapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ExchangePublic : public ExchangeBase {
std::optional<MonetaryAmount> computeAvgOrderPrice(Market mk, MonetaryAmount from, const PriceOptions &priceOptions);

/// Retrieve the market in the correct order proposed by the exchange for given couple of currencies.
std::optional<Market> retrieveMarket(CurrencyCode c1, CurrencyCode c2, const MarketSet &markets);
static std::optional<Market> RetrieveMarket(CurrencyCode c1, CurrencyCode c2, const MarketSet &markets);

std::optional<Market> retrieveMarket(CurrencyCode c1, CurrencyCode c2);

Expand Down
1 change: 1 addition & 0 deletions src/api/common/src/commonapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "httprequesttype.hpp"
#include "permanentcurloptions.hpp"
#include "timedef.hpp"
#include "withdrawalfees-crawler.hpp"

namespace cct::api {
namespace {
Expand Down
5 changes: 3 additions & 2 deletions src/api/common/src/exchangepublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cmath>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <mutex>
#include <optional>
Expand Down Expand Up @@ -294,7 +295,7 @@ std::optional<MonetaryAmount> ExchangePublic::computeAvgOrderPrice(Market mk, Mo
return queryOrderBook(mk, depth).computeAvgPrice(from, priceOptions);
}

std::optional<Market> ExchangePublic::retrieveMarket(CurrencyCode c1, CurrencyCode c2, const MarketSet &markets) {
std::optional<Market> ExchangePublic::RetrieveMarket(CurrencyCode c1, CurrencyCode c2, const MarketSet &markets) {
Market mk(c1, c2);
if (!markets.contains(mk)) {
mk = mk.reverse();
Expand All @@ -307,7 +308,7 @@ std::optional<Market> ExchangePublic::retrieveMarket(CurrencyCode c1, CurrencyCo

std::optional<Market> ExchangePublic::retrieveMarket(CurrencyCode c1, CurrencyCode c2) {
std::lock_guard<std::mutex> guard(_tradableMarketsMutex);
return retrieveMarket(c1, c2, queryTradableMarkets());
return RetrieveMarket(c1, c2, queryTradableMarkets());
}

MarketPriceMap ExchangePublic::MarketPriceMapFromMarketOrderBookMap(const MarketOrderBookMap &marketOrderBookMap) {
Expand Down
1 change: 1 addition & 0 deletions src/api/common/src/fiatconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "httprequesttype.hpp"
#include "market.hpp"
#include "permanentcurloptions.hpp"
#include "reader.hpp"
#include "timedef.hpp"

namespace cct {
Expand Down
2 changes: 2 additions & 0 deletions src/api/common/src/withdrawalfees-crawler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string_view>
#include <utility>

#include "cachedresult.hpp"
#include "cachedresultvault.hpp"
#include "cct_cctype.hpp"
#include "cct_const.hpp"
Expand All @@ -18,6 +19,7 @@
#include "file.hpp"
#include "httprequesttype.hpp"
#include "monetaryamount.hpp"
#include "permanentcurloptions.hpp"
#include "timedef.hpp"

namespace cct {
Expand Down
1 change: 1 addition & 0 deletions src/api/common/test/exchangeprivateapi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "orderid.hpp"
#include "priceoptions.hpp"
#include "priceoptionsdef.hpp"
#include "reader.hpp"
#include "runmodes.hpp"
#include "stringhelpers.hpp"
#include "timedef.hpp"
Expand Down
5 changes: 2 additions & 3 deletions src/api/common/test/exchangepublicapi_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <optional>

#include "cct_const.hpp"
#include "cct_exception.hpp"
#include "cct_string.hpp"
#include "coincenterinfo.hpp"
#include "commonapi.hpp"
Expand Down Expand Up @@ -109,8 +108,8 @@ TEST_F(ExchangePublicTest, RetrieveMarket) {
EXPECT_CALL(exchangePublic, queryTradableMarkets()).WillOnce(::testing::Return(markets));

EXPECT_EQ(exchangePublic.retrieveMarket("BTC", "KRW").value(), Market("BTC", "KRW"));
EXPECT_EQ(exchangePublic.retrieveMarket("KRW", "BTC", markets).value(), Market("BTC", "KRW"));
EXPECT_FALSE(exchangePublic.retrieveMarket("EUR", "EOS", markets).has_value());
EXPECT_EQ(ExchangePublic::RetrieveMarket("KRW", "BTC", markets).value(), Market("BTC", "KRW"));
EXPECT_FALSE(ExchangePublic::RetrieveMarket("EUR", "EOS", markets).has_value());
}

class ExchangePublicConvertTest : public ExchangePublicTest {
Expand Down
2 changes: 2 additions & 0 deletions src/api/common/test/withdrawalfees-crawler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <gtest/gtest.h>

#include <string_view>

#include "cachedresultvault.hpp"
#include "cct_const.hpp"
#include "coincenterinfo.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/api/exchanges/src/binancepublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "market.hpp"
#include "marketorderbook.hpp"
#include "monetaryamount.hpp"
#include "monetaryamountbycurrencyset.hpp"
#include "permanentcurloptions.hpp"
#include "runmodes.hpp"
#include "timedef.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/api/exchanges/src/bithumbprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "exchangename.hpp"
#include "exchangeprivateapi.hpp"
#include "exchangeprivateapitypes.hpp"
#include "exchangepublicapi.hpp"
#include "exchangepublicapitypes.hpp"
#include "file.hpp"
#include "httprequesttype.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/engine/src/queryresultprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "cct_json.hpp"
#include "cct_log.hpp"
#include "cct_string.hpp"
#include "closed-order.hpp"
#include "coincentercommandtype.hpp"
#include "currencycode.hpp"
#include "currencycodevector.hpp"
Expand All @@ -27,7 +28,7 @@
#include "market.hpp"
#include "marketorderbook.hpp"
#include "monetaryamount.hpp"
#include "order.hpp"
#include "opened-order.hpp"
#include "orderid.hpp"
#include "ordersconstraints.hpp"
#include "priceoptions.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/engine/test/exchangesorchestrator_private_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "exchangeprivateapitypes.hpp"
#include "exchangesorchestrator.hpp"
#include "monetaryamount.hpp"
#include "order.hpp"
#include "opened-order.hpp"
#include "ordersconstraints.hpp"
#include "queryresulttypes.hpp"
#include "timedef.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/objects/src/coincentercommandtype.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "coincentercommandtype.hpp"

#include <algorithm>
#include <cstddef>
#include <string_view>
#include <type_traits>

Expand Down
28 changes: 16 additions & 12 deletions src/tech/src/simpletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include <ostream>
#include <span>
#include <string_view>
#include <type_traits>
#include <variant>

#include "mathhelpers.hpp"
#include "unreachable.hpp"

namespace cct {

Expand Down Expand Up @@ -44,16 +44,18 @@ class Align {

SimpleTable::size_type SimpleTable::Cell::size() const noexcept {
return std::visit(
[](auto &&v) -> size_type {
using T = std::decay_t<decltype(v)>;
[](auto &&val) -> size_type {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_same_v<T, string_type> || std::is_same_v<T, std::string_view>) {
return v.size();
return val.size();
} else if constexpr (std::is_same_v<T, bool>) {
return v ? kBoolValueTrue.size() : kBoolValueFalse.size();
return val ? kBoolValueTrue.size() : kBoolValueFalse.size();
} else if constexpr (std::is_integral_v<T>) {
return nchars(v);
return nchars(val);
} else {
unreachable();
// Note: below ugly template lambda can be replaced with 'static_assert(false);' in C++23
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
}
},
_data);
Expand All @@ -63,15 +65,17 @@ void SimpleTable::Cell::print(std::ostream &os, size_type maxCellWidth) const {
os << ' ' << Align(AlignTo::kLeft) << std::setw(maxCellWidth);

std::visit(
[&os](auto &&v) {
using T = std::decay_t<decltype(v)>;
[&os](auto &&val) {
using T = std::decay_t<decltype(val)>;
if constexpr (std::is_same_v<T, bool>) {
os << (v ? kBoolValueTrue : kBoolValueFalse);
os << (val ? kBoolValueTrue : kBoolValueFalse);
} else if constexpr (std::is_same_v<T, string_type> || std::is_same_v<T, std::string_view> ||
std::is_integral_v<T>) {
os << v;
os << val;
} else {
unreachable();
// Note: below ugly template lambda can be replaced with 'static_assert(false);' in C++23
[]<bool flag = false>() { static_assert(flag, "no match"); }
();
}
},
_data);
Expand Down

0 comments on commit 8092696

Please sign in to comment.