From 8da440ea1f3efa1630727a4b4ddcdcf1cd9c42f6 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 2 Feb 2025 01:35:19 -0600 Subject: [PATCH] General linter cleanup --- wxdata/source/scwx/awips/wmo_header.cpp | 17 +++++++++++------ .../scwx/provider/iem_warnings_provider.cpp | 5 ++++- wxdata/source/scwx/util/json.cpp | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/wxdata/source/scwx/awips/wmo_header.cpp b/wxdata/source/scwx/awips/wmo_header.cpp index 4d502604..a701e476 100644 --- a/wxdata/source/scwx/awips/wmo_header.cpp +++ b/wxdata/source/scwx/awips/wmo_header.cpp @@ -12,14 +12,14 @@ # include #endif -namespace scwx -{ -namespace awips +namespace scwx::awips { static const std::string logPrefix_ = "scwx::awips::wmo_header"; static const auto logger_ = util::Logger::Create(logPrefix_); +static constexpr std::size_t kWmoHeaderMinLineLength_ = 18; + class WmoHeaderImpl { public: @@ -37,6 +37,11 @@ public: } ~WmoHeaderImpl() = default; + WmoHeaderImpl(const WmoHeaderImpl&) = delete; + WmoHeaderImpl& operator=(const WmoHeaderImpl&) = delete; + WmoHeaderImpl(const WmoHeaderImpl&&) = delete; + WmoHeaderImpl& operator=(const WmoHeaderImpl&&) = delete; + bool operator==(const WmoHeaderImpl& o) const; std::string sequenceNumber_; @@ -138,8 +143,9 @@ bool WmoHeader::Parse(std::istream& is) { // The next line could be the WMO line or the sequence line util::getline(is, wmoLine); - if (wmoLine.length() < 18) + if (wmoLine.length() < kWmoHeaderMinLineLength_) { + // This is likely the sequence line instead sequenceLine.swap(wmoLine); util::getline(is, wmoLine); } @@ -249,5 +255,4 @@ bool WmoHeader::Parse(std::istream& is) return headerValid; } -} // namespace awips -} // namespace scwx +} // namespace scwx::awips diff --git a/wxdata/source/scwx/provider/iem_warnings_provider.cpp b/wxdata/source/scwx/provider/iem_warnings_provider.cpp index 47c29547..4bbd339a 100644 --- a/wxdata/source/scwx/provider/iem_warnings_provider.cpp +++ b/wxdata/source/scwx/provider/iem_warnings_provider.cpp @@ -144,13 +144,16 @@ IemWarningsProvider::LoadTextProducts( std::vector> asyncResponses {}; + asyncResponses.reserve(textProducts.size()); + + const std::string endpointUrl = kBaseUrl_ + kNwsTextProductEndpoint_; for (auto& productId : textProducts) { asyncResponses.emplace_back( productId, cpr::GetAsync( - cpr::Url {kBaseUrl_ + kNwsTextProductEndpoint_ + productId}, + cpr::Url {endpointUrl + productId}, network::cpr::GetHeader(), parameters)); } diff --git a/wxdata/source/scwx/util/json.cpp b/wxdata/source/scwx/util/json.cpp index b8f51507..d5873758 100644 --- a/wxdata/source/scwx/util/json.cpp +++ b/wxdata/source/scwx/util/json.cpp @@ -107,6 +107,8 @@ void WriteJsonFile(const std::string& path, } } +// Allow recursion within the pretty print function +// NOLINTNEXTLINE(misc-no-recursion) static void PrettyPrintJson(std::ostream& os, boost::json::value const& jv, std::string* indent)