diff --git a/src/api/common/src/commonapi.cpp b/src/api/common/src/commonapi.cpp index 506f942c..f71b8e75 100644 --- a/src/api/common/src/commonapi.cpp +++ b/src/api/common/src/commonapi.cpp @@ -1,14 +1,15 @@ #include "commonapi.hpp" #include +#include #include #include #include "cachedresult.hpp" -#include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" #include "cct_string.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" #include "curloptions.hpp" #include "currencycode.hpp" diff --git a/src/api/common/src/exchangepublicapi.cpp b/src/api/common/src/exchangepublicapi.cpp index b5640fdc..5c1d8876 100644 --- a/src/api/common/src/exchangepublicapi.cpp +++ b/src/api/common/src/exchangepublicapi.cpp @@ -2,7 +2,10 @@ #include #include +#include #include +#include +#include #include #include #include @@ -104,7 +107,7 @@ namespace { // Struct containing a currency and additional information to create markets with detailed information (order, market // type) struct CurrencyDir { - constexpr auto operator<=>(const CurrencyDir &) const noexcept = default; + constexpr std::strong_ordering operator<=>(const CurrencyDir &) const noexcept = default; CurrencyCode cur; bool isLastRealMarketReversed = false; diff --git a/src/api/common/src/withdrawalfees-crawler.cpp b/src/api/common/src/withdrawalfees-crawler.cpp index 6d5f766e..e7b22330 100644 --- a/src/api/common/src/withdrawalfees-crawler.cpp +++ b/src/api/common/src/withdrawalfees-crawler.cpp @@ -7,12 +7,17 @@ #include "cachedresultvault.hpp" #include "cct_cctype.hpp" +#include "cct_const.hpp" +#include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" #include "curloptions.hpp" +#include "currencycode.hpp" #include "file.hpp" #include "httprequesttype.hpp" +#include "monetaryamount.hpp" #include "timedef.hpp" namespace cct { diff --git a/src/api/common/test/commonapi_test.cpp b/src/api/common/test/commonapi_test.cpp index f5a4ead8..f4d8b137 100644 --- a/src/api/common/test/commonapi_test.cpp +++ b/src/api/common/test/commonapi_test.cpp @@ -5,6 +5,7 @@ #include "coincenterinfo.hpp" #include "runmodes.hpp" +#include "timedef.hpp" namespace cct::api { diff --git a/src/api/common/test/exchangepublicapi_test.cpp b/src/api/common/test/exchangepublicapi_test.cpp index dedfde9c..08e2eba2 100644 --- a/src/api/common/test/exchangepublicapi_test.cpp +++ b/src/api/common/test/exchangepublicapi_test.cpp @@ -7,6 +7,7 @@ #include "cct_const.hpp" #include "cct_exception.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" #include "commonapi.hpp" #include "currencycode.hpp" @@ -28,7 +29,7 @@ namespace cct::api { namespace { class StableCoinReader : public Reader { - string readAll() const override { return R"({"USDT": "USD"})"; } + [[nodiscard]] string readAll() const override { return R"({"USDT": "USD"})"; } }; } // namespace class ExchangePublicTest : public ::testing::Test { diff --git a/src/api/common/test/fiatconverter_test.cpp b/src/api/common/test/fiatconverter_test.cpp index f94f6baf..087a8c3f 100644 --- a/src/api/common/test/fiatconverter_test.cpp +++ b/src/api/common/test/fiatconverter_test.cpp @@ -34,7 +34,7 @@ CurlHandle::CurlHandle([[maybe_unused]] BestURLPicker bestURLPicker, [[maybe_unused]] AbstractMetricGateway *pMetricGateway, [[maybe_unused]] const PermanentCurlOptions &permanentCurlOptions, [[maybe_unused]] settings::RunMode runMode) - : _handle(nullptr), _bestUrlPicker(kSomeFakeURL) {} + : _bestURLPicker(kSomeFakeURL) {} // NOLINTNEXTLINE(readability-convert-member-functions-to-static) std::string_view CurlHandle::query([[maybe_unused]] std::string_view endpoint, const CurlOptions &opts) { diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index bbe01781..dbc75c07 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -38,6 +38,7 @@ #include "httprequesttype.hpp" #include "market.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "order.hpp" #include "orderid.hpp" #include "ordersconstraints.hpp" diff --git a/src/api/exchanges/src/huobipublicapi.cpp b/src/api/exchanges/src/huobipublicapi.cpp index e68efe87..cabaa051 100644 --- a/src/api/exchanges/src/huobipublicapi.cpp +++ b/src/api/exchanges/src/huobipublicapi.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -12,7 +11,6 @@ #include "apiquerytypeenum.hpp" #include "cachedresult.hpp" -#include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" #include "cct_string.hpp" @@ -34,6 +32,7 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "permanentcurloptions.hpp" #include "timedef.hpp" #include "toupperlower-string.hpp" diff --git a/src/api/exchanges/src/krakenpublicapi.cpp b/src/api/exchanges/src/krakenpublicapi.cpp index 79cd685a..e458d1a3 100644 --- a/src/api/exchanges/src/krakenpublicapi.cpp +++ b/src/api/exchanges/src/krakenpublicapi.cpp @@ -31,6 +31,7 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "permanentcurloptions.hpp" #include "timedef.hpp" #include "tradeside.hpp" diff --git a/src/api/exchanges/src/kucoinpublicapi.cpp b/src/api/exchanges/src/kucoinpublicapi.cpp index 3ba25a50..1fccf69b 100644 --- a/src/api/exchanges/src/kucoinpublicapi.cpp +++ b/src/api/exchanges/src/kucoinpublicapi.cpp @@ -10,7 +10,6 @@ #include "apiquerytypeenum.hpp" #include "cachedresult.hpp" -#include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" #include "cct_string.hpp" @@ -32,6 +31,7 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "permanentcurloptions.hpp" #include "stringhelpers.hpp" #include "timedef.hpp" diff --git a/src/api/exchanges/src/upbitprivateapi.cpp b/src/api/exchanges/src/upbitprivateapi.cpp index b53011d6..5c2724e5 100644 --- a/src/api/exchanges/src/upbitprivateapi.cpp +++ b/src/api/exchanges/src/upbitprivateapi.cpp @@ -589,7 +589,7 @@ OrderInfo UpbitPrivate::queryOrderInfo(OrderIdView orderId, const TradeContext& std::optional UpbitPrivate::WithdrawFeesFunc::operator()(CurrencyCode currencyCode) { auto curStr = currencyCode.str(); json result = PrivateQuery(_curlHandle, _apiKey, HttpRequestType::kGet, "/v1/withdraws/chance", - {{"currency", std::string_view(curStr)}, {"net_type", std::string_view(curStr)}}); + {{"currency", std::string_view{curStr}}, {"net_type", std::string_view{curStr}}}); std::string_view amountStr = result["currency"]["withdraw_fee"].get(); return MonetaryAmount(amountStr, currencyCode); } diff --git a/src/api/exchanges/src/upbitpublicapi.cpp b/src/api/exchanges/src/upbitpublicapi.cpp index 36cb8067..a769cba2 100644 --- a/src/api/exchanges/src/upbitpublicapi.cpp +++ b/src/api/exchanges/src/upbitpublicapi.cpp @@ -31,6 +31,7 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "permanentcurloptions.hpp" #include "timedef.hpp" #include "tradeside.hpp" diff --git a/src/engine/src/exchangesorchestrator.cpp b/src/engine/src/exchangesorchestrator.cpp index 7aea0d7d..b1c0539e 100644 --- a/src/engine/src/exchangesorchestrator.cpp +++ b/src/engine/src/exchangesorchestrator.cpp @@ -33,6 +33,7 @@ #include "market.hpp" #include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "ordersconstraints.hpp" #include "queryresulttypes.hpp" #include "requestsconfig.hpp" diff --git a/src/engine/src/queryresultprinter.cpp b/src/engine/src/queryresultprinter.cpp index f256a184..2ec582d1 100644 --- a/src/engine/src/queryresultprinter.cpp +++ b/src/engine/src/queryresultprinter.cpp @@ -11,7 +11,6 @@ #include "apioutputtype.hpp" #include "balanceperexchangeportfolio.hpp" -#include "cct_const.hpp" #include "cct_json.hpp" #include "cct_log.hpp" #include "cct_string.hpp" @@ -32,6 +31,7 @@ #include "orderid.hpp" #include "ordersconstraints.hpp" #include "priceoptions.hpp" +#include "priceoptionsdef.hpp" #include "publictrade.hpp" #include "queryresulttypes.hpp" #include "simpletable.hpp" diff --git a/src/engine/test/queryresultprinter_public_test.cpp b/src/engine/test/queryresultprinter_public_test.cpp index dac8af9a..b327fc59 100644 --- a/src/engine/test/queryresultprinter_public_test.cpp +++ b/src/engine/test/queryresultprinter_public_test.cpp @@ -9,6 +9,7 @@ #include "exchangepublicapitypes.hpp" #include "market.hpp" #include "marketorderbook.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "publictrade.hpp" #include "queryresultprinter.hpp" #include "queryresultprinter_base_test.hpp" diff --git a/src/http-request/include/curlhandle.hpp b/src/http-request/include/curlhandle.hpp index 05328db5..1754b42e 100644 --- a/src/http-request/include/curlhandle.hpp +++ b/src/http-request/include/curlhandle.hpp @@ -51,7 +51,7 @@ class CurlHandle { /// The pointed memory is valid until a next call to 'query'. std::string_view query(std::string_view endpoint, const CurlOptions &opts); - std::string_view getNextBaseUrl() const { return _bestUrlPicker.getNextBaseURL(); } + std::string_view getNextBaseUrl() const { return _bestURLPicker.getNextBaseURL(); } Duration minDurationBetweenQueries() const { return _minDurationBetweenQueries; } @@ -78,7 +78,7 @@ class CurlHandle { AbstractMetricGateway *_pMetricGateway = nullptr; // non-owning pointer Duration _minDurationBetweenQueries{}; TimePoint _lastQueryTime{}; - BestURLPicker _bestUrlPicker; + BestURLPicker _bestURLPicker; string _queryData; log::level::level_enum _requestCallLogLevel = log::level::level_enum::off; log::level::level_enum _requestAnswerLogLevel = log::level::level_enum::off; diff --git a/src/http-request/src/curlhandle.cpp b/src/http-request/src/curlhandle.cpp index dd1a0468..d5f575ed 100644 --- a/src/http-request/src/curlhandle.cpp +++ b/src/http-request/src/curlhandle.cpp @@ -80,7 +80,7 @@ CurlHandle::CurlHandle(BestURLPicker bestURLPicker, AbstractMetricGateway *pMetr const PermanentCurlOptions &permanentCurlOptions, settings::RunMode runMode) : _pMetricGateway(pMetricGateway), _minDurationBetweenQueries(permanentCurlOptions.minDurationBetweenQueries()), - _bestUrlPicker(std::move(bestURLPicker)), + _bestURLPicker(std::move(bestURLPicker)), _requestCallLogLevel(permanentCurlOptions.requestCallLogLevel()), _requestAnswerLogLevel(permanentCurlOptions.requestAnswerLogLevel()), _nbMaxRetries(permanentCurlOptions.nbMaxRetries()), @@ -120,7 +120,7 @@ CurlHandle::CurlHandle(BestURLPicker bestURLPicker, AbstractMetricGateway *pMetr #endif log::debug("Initialize CurlHandle for {} with {} as minimum duration between queries", - bestURLPicker.getNextBaseURL(), DurationToString(_minDurationBetweenQueries)); + _bestURLPicker.getNextBaseURL(), DurationToString(_minDurationBetweenQueries)); if (settings::IsProxyRequested(runMode)) { if (IsProxyAvailable()) { @@ -151,8 +151,8 @@ std::string_view CurlHandle::query(std::string_view endpoint, const CurlOptions const bool appendParametersInQueryStr = !postData.empty() && (opts.requestType() != HttpRequestType::kPost || queryResponseOverrideMode); - const int8_t baseUrlPos = _bestUrlPicker.nextBaseURLPos(); - const std::string_view baseUrl = _bestUrlPicker.getBaseURL(baseUrlPos); + const int8_t baseUrlPos = _bestURLPicker.nextBaseURLPos(); + const std::string_view baseUrl = _bestURLPicker.getBaseURL(baseUrlPos); const std::string_view postDataStr = postData.str(); string modifiedURL(baseUrl.size() + endpoint.size() + (appendParametersInQueryStr ? (1U + postDataStr.size()) : 0U), '?'); @@ -262,7 +262,7 @@ std::string_view CurlHandle::query(std::string_view endpoint, const CurlOptions // Store stats const auto queryRTInMs = static_cast(GetTimeFrom(t1).count()); - _bestUrlPicker.storeResponseTimePerBaseURL(baseUrlPos, queryRTInMs); + _bestURLPicker.storeResponseTimePerBaseURL(baseUrlPos, queryRTInMs); if (_pMetricGateway != nullptr) { _pMetricGateway->add(MetricType::kCounter, MetricOperation::kIncrement, @@ -274,7 +274,7 @@ std::string_view CurlHandle::query(std::string_view endpoint, const CurlOptions // Periodic memory release to avoid memory leak for a very large number of requests static constexpr int kReleaseMemoryRequestsFrequency = 100; - if ((_bestUrlPicker.nbRequestsDone() % kReleaseMemoryRequestsFrequency) == 0) { + if ((_bestURLPicker.nbRequestsDone() % kReleaseMemoryRequestsFrequency) == 0) { _queryData.shrink_to_fit(); } @@ -332,7 +332,7 @@ void CurlHandle::swap(CurlHandle &rhs) noexcept { swap(_pMetricGateway, rhs._pMetricGateway); swap(_minDurationBetweenQueries, rhs._minDurationBetweenQueries); swap(_lastQueryTime, rhs._lastQueryTime); - swap(_bestUrlPicker, rhs._bestUrlPicker); + swap(_bestURLPicker, rhs._bestURLPicker); _queryData.swap(rhs._queryData); swap(_requestCallLogLevel, rhs._requestCallLogLevel); swap(_requestAnswerLogLevel, rhs._requestAnswerLogLevel); diff --git a/src/http-request/test/curlhandle_test.cpp b/src/http-request/test/curlhandle_test.cpp index 70c6eb8f..4d11838e 100644 --- a/src/http-request/test/curlhandle_test.cpp +++ b/src/http-request/test/curlhandle_test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "cct_exception.hpp" #include "curloptions.hpp" diff --git a/src/objects/include/file.hpp b/src/objects/include/file.hpp index 5d43ef4e..85cd88a0 100644 --- a/src/objects/include/file.hpp +++ b/src/objects/include/file.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "cct_json.hpp" #include "cct_string.hpp" #include "reader.hpp" @@ -14,7 +17,7 @@ class File : public Reader, public Writer { File(std::string_view dataDir, Type type, std::string_view name, IfError ifError); - string readAll() const override; + [[nodiscard]] string readAll() const override; int write(const json &data, Writer::Mode mode = Writer::Mode::FromStart) const override; diff --git a/src/objects/include/reader.hpp b/src/objects/include/reader.hpp index a683fae4..8b00d76d 100644 --- a/src/objects/include/reader.hpp +++ b/src/objects/include/reader.hpp @@ -12,7 +12,7 @@ class Reader { virtual ~Reader() = default; // Read all content and return a string of it. - virtual string readAll() const { return {}; } + [[nodiscard]] virtual string readAll() const { return {}; } // Read all content, and constructs a json object from it. json readAllJson() const; diff --git a/src/objects/src/exchangeconfig.cpp b/src/objects/src/exchangeconfig.cpp index 4cfa4a24..8c325e66 100644 --- a/src/objects/src/exchangeconfig.cpp +++ b/src/objects/src/exchangeconfig.cpp @@ -16,6 +16,7 @@ #include "monetaryamount.hpp" #include "monetaryamountbycurrencyset.hpp" #include "timedef.hpp" +#include "tradeconfig.hpp" namespace cct { diff --git a/src/objects/src/exchangeconfigmap.cpp b/src/objects/src/exchangeconfigmap.cpp index 1f1cabc2..905bfc90 100644 --- a/src/objects/src/exchangeconfigmap.cpp +++ b/src/objects/src/exchangeconfigmap.cpp @@ -15,6 +15,8 @@ #include "parseloglevel.hpp" #include "priceoptionsdef.hpp" #include "timedef.hpp" +#include "tradeconfig.hpp" +#include "tradedefinitions.hpp" namespace cct { diff --git a/src/objects/src/marketorderbook.cpp b/src/objects/src/marketorderbook.cpp index 93918c4a..1b3d64dd 100644 --- a/src/objects/src/marketorderbook.cpp +++ b/src/objects/src/marketorderbook.cpp @@ -19,6 +19,7 @@ #include "priceoptions.hpp" #include "priceoptionsdef.hpp" #include "simpletable.hpp" +#include "timedef.hpp" #include "unreachable.hpp" #include "volumeandpricenbdecimals.hpp" diff --git a/src/objects/src/priceoptions.cpp b/src/objects/src/priceoptions.cpp index a59f19a0..c81eecca 100644 --- a/src/objects/src/priceoptions.cpp +++ b/src/objects/src/priceoptions.cpp @@ -4,6 +4,7 @@ #include "cct_invalid_argument_exception.hpp" #include "cct_string.hpp" +#include "monetaryamount.hpp" #include "priceoptionsdef.hpp" #include "tradeconfig.hpp" diff --git a/src/objects/test/exchangename_test.cpp b/src/objects/test/exchangename_test.cpp index 147762eb..2065284c 100644 --- a/src/objects/test/exchangename_test.cpp +++ b/src/objects/test/exchangename_test.cpp @@ -3,6 +3,7 @@ #include #include "cct_exception.hpp" +#include "cct_log.hpp" namespace cct { TEST(ExchangeName, NoKeyName) { diff --git a/src/objects/test/market_test.cpp b/src/objects/test/market_test.cpp index c9fdd98e..2da134fa 100644 --- a/src/objects/test/market_test.cpp +++ b/src/objects/test/market_test.cpp @@ -2,6 +2,9 @@ #include +#include "cct_exception.hpp" +#include "currencycode.hpp" + namespace cct { TEST(MarketTest, DefaultConstructor) { Market market; diff --git a/src/tech/include/fbstring.hpp b/src/tech/include/fbstring.hpp index 23f0e7d8..f10bb486 100644 --- a/src/tech/include/fbstring.hpp +++ b/src/tech/include/fbstring.hpp @@ -533,7 +533,7 @@ class fbstring_core { void push_back(Char c) { *expandNoinit(1, /* expGrowth = */ true) = c; } - size_t size() const { + size_t size() const noexcept { size_t ret = ml_.size_; if constexpr (kIsLittleEndian) { // We can save a couple instructions, because the category is @@ -549,7 +549,7 @@ class fbstring_core { return ret; } - size_t capacity() const { + size_t capacity() const noexcept { FOLLY_PUSH_WARNING FOLLY_CLANG_DISABLE_WARNING("-Wcovered-switch-default") switch (category()) { @@ -1338,15 +1338,15 @@ class basic_fbstring { } // C++11 21.4.4 capacity: - size_type size() const { return store_.size(); } + size_type size() const noexcept { return store_.size(); } - size_type length() const { return size(); } + size_type length() const noexcept { return size(); } - size_type max_size() const { return std::numeric_limits::max(); } + size_type max_size() const noexcept { return std::numeric_limits::max(); } void resize(size_type n, value_type c = value_type()); - size_type capacity() const { return store_.capacity(); } + size_type capacity() const noexcept { return store_.capacity(); } void reserve(size_type res_arg = 0) { enforce(res_arg <= max_size(), ""); diff --git a/src/tech/include/simpletable.hpp b/src/tech/include/simpletable.hpp index 71c86ff1..1f5269e4 100644 --- a/src/tech/include/simpletable.hpp +++ b/src/tech/include/simpletable.hpp @@ -1,12 +1,11 @@ #pragma once #include -#include #include -#include #include #include #include +#include #include #include #ifdef CCT_MSVC @@ -44,23 +43,23 @@ class SimpleTable { using value_type = std::variant; using size_type = uint32_t; - explicit Cell(std::string_view v = std::string_view()) : _data(v) {} + explicit Cell(std::string_view sv = std::string_view()) : _data(sv) {} - explicit Cell(const char *v) : _data(std::string_view(v)) {} + explicit Cell(const char *cstr) : _data(std::string_view(cstr)) {} #ifdef CCT_MSVC explicit Cell(const string &v) : _data(std::string(v.data(), v.size())) {} #else - explicit Cell(const string_type &v) : _data(v) {} + explicit Cell(const string_type &str) : _data(str) {} - explicit Cell(string_type &&v) : _data(std::move(v)) {} + explicit Cell(string_type &&str) : _data(std::move(str)) {} #endif - explicit Cell(std::integral auto v) : _data(v) {} + explicit Cell(std::integral auto val) : _data(val) {} size_type size() const noexcept; - void swap(Cell &o) noexcept { _data.swap(o._data); } + void swap(Cell &rhs) noexcept { _data.swap(rhs._data); } using trivially_relocatable = is_trivially_relocatable::type; @@ -104,8 +103,8 @@ class SimpleTable { value_type &back() { return _cells.back(); } const value_type &back() const { return _cells.back(); } - void push_back(const Cell &c) { _cells.push_back(c); } - void push_back(Cell &&c) { _cells.push_back(std::move(c)); } + void push_back(const Cell &cell) { _cells.push_back(cell); } + void push_back(Cell &&cell) { _cells.push_back(std::move(cell)); } template value_type &emplace_back(Args &&...args) { @@ -168,7 +167,7 @@ class SimpleTable { const value_type &operator[](size_type rowPos) const { return _rows[rowPos]; } - void reserve(size_type s) { _rows.reserve(s); } + void reserve(size_type sz) { _rows.reserve(sz); } friend std::ostream &operator<<(std::ostream &os, const SimpleTable &t); diff --git a/src/tech/src/gethostname.cpp b/src/tech/src/gethostname.cpp index 3bcdddbe..e5a9e566 100644 --- a/src/tech/src/gethostname.cpp +++ b/src/tech/src/gethostname.cpp @@ -1,5 +1,6 @@ #include "gethostname.hpp" +// NOLINTNEXTLINE(misc-include-cleaner) #include "cct_config.hpp" #include "cct_exception.hpp" #include "cct_string.hpp" diff --git a/src/tech/test/simpletable_test.cpp b/src/tech/test/simpletable_test.cpp index fcba5abe..85e868f3 100644 --- a/src/tech/test/simpletable_test.cpp +++ b/src/tech/test/simpletable_test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "cct_string.hpp"