mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 22:30:04 +00:00
Archive warnings clang-tidy fixes
This commit is contained in:
parent
8cdd8526eb
commit
81f09e07f0
14 changed files with 43 additions and 46 deletions
|
|
@ -10,6 +10,7 @@ Checks:
|
||||||
- '-cppcoreguidelines-pro-type-reinterpret-cast'
|
- '-cppcoreguidelines-pro-type-reinterpret-cast'
|
||||||
- '-misc-include-cleaner'
|
- '-misc-include-cleaner'
|
||||||
- '-misc-non-private-member-variables-in-classes'
|
- '-misc-non-private-member-variables-in-classes'
|
||||||
|
- '-misc-use-anonymous-namespace'
|
||||||
- '-modernize-return-braced-init-list'
|
- '-modernize-return-braced-init-list'
|
||||||
- '-modernize-use-trailing-return-type'
|
- '-modernize-use-trailing-return-type'
|
||||||
FormatStyle: 'file'
|
FormatStyle: 'file'
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
@ -70,7 +71,7 @@ public:
|
||||||
class MarkerManager::Impl::MarkerRecord
|
class MarkerManager::Impl::MarkerRecord
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MarkerRecord(const types::MarkerInfo& info) : markerInfo_ {info} {}
|
MarkerRecord(types::MarkerInfo info) : markerInfo_ {std::move(info)} {}
|
||||||
|
|
||||||
const types::MarkerInfo& toMarkerInfo() { return markerInfo_; }
|
const types::MarkerInfo& toMarkerInfo() { return markerInfo_; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ void TextEventManager::SelectTime(
|
||||||
|
|
||||||
boost::asio::post(
|
boost::asio::post(
|
||||||
p->threadPool_,
|
p->threadPool_,
|
||||||
[=, this]()
|
[this]()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -259,7 +259,7 @@ void TextEventManager::SelectTime(
|
||||||
date < p->archiveLimit_;
|
date < p->archiveLimit_;
|
||||||
});
|
});
|
||||||
|
|
||||||
std::unique_lock lock {p->archiveMutex_};
|
const std::unique_lock lock {p->archiveMutex_};
|
||||||
|
|
||||||
p->UpdateArchiveDates(dates);
|
p->UpdateArchiveDates(dates);
|
||||||
p->ListArchives(dates);
|
p->ListArchives(dates);
|
||||||
|
|
@ -382,7 +382,7 @@ void TextEventManager::Impl::ListArchives(DateRange dates)
|
||||||
auto productEntries = provider::IemApiProvider::ListTextProducts(
|
auto productEntries = provider::IemApiProvider::ListTextProducts(
|
||||||
dateArray | ranges::views::all, kEmptyRange_, kPilsView_);
|
dateArray | ranges::views::all, kEmptyRange_, kPilsView_);
|
||||||
|
|
||||||
std::unique_lock lock {unloadedProductMapMutex_};
|
const std::unique_lock lock {unloadedProductMapMutex_};
|
||||||
|
|
||||||
if (productEntries.has_value())
|
if (productEntries.has_value())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
static std::shared_ptr<TimelineManager> Instance();
|
static std::shared_ptr<TimelineManager> Instance();
|
||||||
|
|
||||||
std::chrono::system_clock::time_point GetSelectedTime() const;
|
[[nodiscard]] std::chrono::system_clock::time_point GetSelectedTime() const;
|
||||||
|
|
||||||
void SetMapCount(std::size_t mapCount);
|
void SetMapCount(std::size_t mapCount);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ size_t UpdateManager::Impl::PopulateReleases()
|
||||||
// Successful REST API query
|
// Successful REST API query
|
||||||
if (r.status_code == 200)
|
if (r.status_code == 200)
|
||||||
{
|
{
|
||||||
boost::json::value json = util::json::ReadJsonString(r.text);
|
const boost::json::value json = util::json::ReadJsonString(r.text);
|
||||||
if (json == nullptr)
|
if (json == nullptr)
|
||||||
{
|
{
|
||||||
logger_->warn("Response not JSON: {}", r.header["content-type"]);
|
logger_->warn("Response not JSON: {}", r.header["content-type"]);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ TEST(WmoHeader, WmoFields)
|
||||||
{
|
{
|
||||||
std::stringstream ss {kWmoHeaderSample_};
|
std::stringstream ss {kWmoHeaderSample_};
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
EXPECT_EQ(valid, true);
|
EXPECT_EQ(valid, true);
|
||||||
EXPECT_EQ(header.sequence_number(), "887");
|
EXPECT_EQ(header.sequence_number(), "887");
|
||||||
|
|
@ -40,7 +40,7 @@ TEST(WmoHeader, DateHintBeforeParse)
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
header.SetDateHint(2022y / October);
|
header.SetDateHint(2022y / October);
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
EXPECT_EQ(valid, true);
|
EXPECT_EQ(valid, true);
|
||||||
EXPECT_EQ(header.GetDateTime(),
|
EXPECT_EQ(header.GetDateTime(),
|
||||||
|
|
@ -54,7 +54,7 @@ TEST(WmoHeader, DateHintAfterParse)
|
||||||
std::stringstream ss {kWmoHeaderSample_};
|
std::stringstream ss {kWmoHeaderSample_};
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
header.SetDateHint(2022y / October);
|
header.SetDateHint(2022y / October);
|
||||||
|
|
||||||
EXPECT_EQ(valid, true);
|
EXPECT_EQ(valid, true);
|
||||||
|
|
@ -69,7 +69,7 @@ TEST(WmoHeader, EndTimeHintSameMonth)
|
||||||
std::stringstream ss {kWmoHeaderSample_};
|
std::stringstream ss {kWmoHeaderSample_};
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
auto endTimeHint = sys_days {2022y / October / 29d} + 0h + 0min + 0s;
|
auto endTimeHint = sys_days {2022y / October / 29d} + 0h + 0min + 0s;
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ TEST(WmoHeader, EndTimeHintPreviousMonth)
|
||||||
std::stringstream ss {kWmoHeaderSample_};
|
std::stringstream ss {kWmoHeaderSample_};
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
auto endTimeHint = sys_days {2022y / October / 27d} + 0h + 0min + 0s;
|
auto endTimeHint = sys_days {2022y / October / 27d} + 0h + 0min + 0s;
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ TEST(WmoHeader, EndTimeHintPreviousYear)
|
||||||
std::stringstream ss {kWmoHeaderSample_};
|
std::stringstream ss {kWmoHeaderSample_};
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
auto endTimeHint = sys_days {2022y / January / 27d} + 0h + 0min + 0s;
|
auto endTimeHint = sys_days {2022y / January / 27d} + 0h + 0min + 0s;
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ TEST(WmoHeader, EndTimeHintIgnored)
|
||||||
WmoHeader header;
|
WmoHeader header;
|
||||||
|
|
||||||
header.SetDateHint(2022y / October);
|
header.SetDateHint(2022y / October);
|
||||||
bool valid = header.Parse(ss);
|
const bool valid = header.Parse(ss);
|
||||||
|
|
||||||
auto endTimeHint = sys_days {2020y / January / 1d} + 0h + 0min + 0s;
|
auto endTimeHint = sys_days {2020y / January / 1d} + 0h + 0min + 0s;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx::provider
|
||||||
{
|
|
||||||
namespace provider
|
|
||||||
{
|
{
|
||||||
|
|
||||||
TEST(IemApiProviderTest, ListTextProducts)
|
TEST(IemApiProviderTest, ListTextProducts)
|
||||||
|
|
@ -12,11 +10,9 @@ TEST(IemApiProviderTest, ListTextProducts)
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using sys_days = time_point<system_clock, days>;
|
using sys_days = time_point<system_clock, days>;
|
||||||
|
|
||||||
IemApiProvider provider {};
|
|
||||||
|
|
||||||
auto date = sys_days {2023y / March / 25d};
|
auto date = sys_days {2023y / March / 25d};
|
||||||
|
|
||||||
auto torProducts = provider.ListTextProducts(date, {}, "TOR");
|
auto torProducts = IemApiProvider::ListTextProducts(date, {}, "TOR");
|
||||||
|
|
||||||
ASSERT_EQ(torProducts.has_value(), true);
|
ASSERT_EQ(torProducts.has_value(), true);
|
||||||
EXPECT_EQ(torProducts.value().size(), 35);
|
EXPECT_EQ(torProducts.value().size(), 35);
|
||||||
|
|
@ -40,9 +36,7 @@ TEST(IemApiProviderTest, LoadTextProducts)
|
||||||
"202303252015-KFFC-WFUS52-TORFFC",
|
"202303252015-KFFC-WFUS52-TORFFC",
|
||||||
"202303311942-KLZK-WWUS54-SVSLZK"};
|
"202303311942-KLZK-WWUS54-SVSLZK"};
|
||||||
|
|
||||||
IemApiProvider provider {};
|
auto textProducts = IemApiProvider::LoadTextProducts(productIds);
|
||||||
|
|
||||||
auto textProducts = provider.LoadTextProducts(productIds);
|
|
||||||
|
|
||||||
EXPECT_EQ(textProducts.size(), 3);
|
EXPECT_EQ(textProducts.size(), 3);
|
||||||
|
|
||||||
|
|
@ -60,5 +54,4 @@ TEST(IemApiProviderTest, LoadTextProducts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace provider
|
} // namespace scwx::provider
|
||||||
} // namespace scwx
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ TEST_P(WarningsProviderTest, LoadUpdatedFiles)
|
||||||
{
|
{
|
||||||
WarningsProvider provider(GetParam());
|
WarningsProvider provider(GetParam());
|
||||||
|
|
||||||
std::chrono::sys_time<std::chrono::hours> now =
|
const std::chrono::sys_time<std::chrono::hours> now =
|
||||||
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
|
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
|
||||||
std::chrono::sys_time<std::chrono::hours> startTime =
|
const std::chrono::sys_time<std::chrono::hours> startTime =
|
||||||
now - std::chrono::days {3};
|
now - std::chrono::days {3};
|
||||||
|
|
||||||
auto updatedFiles = provider.LoadUpdatedFiles(startTime);
|
auto updatedFiles = provider.LoadUpdatedFiles(startTime);
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public:
|
||||||
TextProductMessage(TextProductMessage&&) noexcept;
|
TextProductMessage(TextProductMessage&&) noexcept;
|
||||||
TextProductMessage& operator=(TextProductMessage&&) noexcept;
|
TextProductMessage& operator=(TextProductMessage&&) noexcept;
|
||||||
|
|
||||||
boost::uuids::uuid uuid() const;
|
[[nodiscard]] boost::uuids::uuid uuid() const;
|
||||||
std::string message_content() const;
|
std::string message_content() const;
|
||||||
std::shared_ptr<WmoHeader> wmo_header() const;
|
std::shared_ptr<WmoHeader> wmo_header() const;
|
||||||
std::vector<std::string> mnd_header() const;
|
std::vector<std::string> mnd_header() const;
|
||||||
|
|
|
||||||
|
|
@ -593,8 +593,8 @@ std::optional<Vtec> TryParseVtecString(std::istream& is)
|
||||||
|
|
||||||
if (RE2::PartialMatch(line, *rePVtecString))
|
if (RE2::PartialMatch(line, *rePVtecString))
|
||||||
{
|
{
|
||||||
vtec = Vtec();
|
vtec = Vtec();
|
||||||
bool vtecValid = vtec->pVtec_.Parse(line);
|
const bool vtecValid = vtec->pVtec_.Parse(line);
|
||||||
|
|
||||||
isBegin = is.tellg();
|
isBegin = is.tellg();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,9 +143,11 @@ std::chrono::sys_time<std::chrono::minutes> WmoHeader::GetDateTime(
|
||||||
{
|
{
|
||||||
std::chrono::sys_time<std::chrono::minutes> wmoDateTime {};
|
std::chrono::sys_time<std::chrono::minutes> wmoDateTime {};
|
||||||
|
|
||||||
if (p->absoluteDateTime_.has_value())
|
const auto absoluteDateTime = p->absoluteDateTime_;
|
||||||
|
|
||||||
|
if (absoluteDateTime.has_value())
|
||||||
{
|
{
|
||||||
wmoDateTime = p->absoluteDateTime_.value();
|
wmoDateTime = absoluteDateTime.value();
|
||||||
}
|
}
|
||||||
else if (endTimeHint.has_value())
|
else if (endTimeHint.has_value())
|
||||||
{
|
{
|
||||||
|
|
@ -160,8 +162,8 @@ std::chrono::sys_time<std::chrono::minutes> WmoHeader::GetDateTime(
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
auto endDays = floor<days>(endTimeHint.value());
|
const auto endDays = floor<days>(endTimeHint.value());
|
||||||
year_month_day endDate {endDays};
|
const year_month_day endDate {endDays};
|
||||||
|
|
||||||
// Combine end date year and month with WMO date time
|
// Combine end date year and month with WMO date time
|
||||||
wmoDateTime =
|
wmoDateTime =
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ IemApiProvider::ListTextProducts(std::chrono::sys_days date,
|
||||||
std::optional<std::string_view> optionalCccc,
|
std::optional<std::string_view> optionalCccc,
|
||||||
std::optional<std::string_view> optionalPil)
|
std::optional<std::string_view> optionalPil)
|
||||||
{
|
{
|
||||||
std::string_view cccc =
|
const std::string_view cccc =
|
||||||
optionalCccc.has_value() ? optionalCccc.value() : std::string_view {};
|
optionalCccc.has_value() ? optionalCccc.value() : std::string_view {};
|
||||||
std::string_view pil =
|
const std::string_view pil =
|
||||||
optionalPil.has_value() ? optionalPil.value() : std::string_view {};
|
optionalPil.has_value() ? optionalPil.value() : std::string_view {};
|
||||||
|
|
||||||
const auto dateArray = std::array {date};
|
const auto dateArray = std::array {date};
|
||||||
|
|
@ -72,7 +72,7 @@ IemApiProvider::ProcessTextProductLists(
|
||||||
{
|
{
|
||||||
auto response = asyncResponse.get();
|
auto response = asyncResponse.get();
|
||||||
|
|
||||||
boost::json::value json = util::json::ReadJsonString(response.text);
|
const boost::json::value json = util::json::ReadJsonString(response.text);
|
||||||
|
|
||||||
if (response.status_code == cpr::status::HTTP_OK)
|
if (response.status_code == cpr::status::HTTP_OK)
|
||||||
{
|
{
|
||||||
|
|
@ -161,7 +161,7 @@ IemApiProvider::ProcessTextProductFiles(
|
||||||
{
|
{
|
||||||
// Load file
|
// Load file
|
||||||
auto& productId = asyncResponse.first;
|
auto& productId = asyncResponse.first;
|
||||||
std::shared_ptr<awips::TextProductFile> textProductFile {
|
const std::shared_ptr<awips::TextProductFile> textProductFile {
|
||||||
std::make_shared<awips::TextProductFile>()};
|
std::make_shared<awips::TextProductFile>()};
|
||||||
std::istringstream responseBody {response.text};
|
std::istringstream responseBody {response.text};
|
||||||
if (textProductFile->LoadData(productId, responseBody))
|
if (textProductFile->LoadData(productId, responseBody))
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
// Enable chrono formatters
|
// Enable chrono formatters
|
||||||
#ifndef __cpp_lib_format
|
#ifndef __cpp_lib_format
|
||||||
|
// NOLINTNEXTLINE(bugprone-reserved-identifier, cppcoreguidelines-macro-usage)
|
||||||
# define __cpp_lib_format 202110L
|
# define __cpp_lib_format 202110L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -106,7 +107,7 @@ WarningsProvider::LoadUpdatedFiles(
|
||||||
asyncCallbacks;
|
asyncCallbacks;
|
||||||
std::vector<std::shared_ptr<awips::TextProductFile>> updatedFiles;
|
std::vector<std::shared_ptr<awips::TextProductFile>> updatedFiles;
|
||||||
|
|
||||||
std::chrono::sys_time<std::chrono::hours> now =
|
const std::chrono::sys_time<std::chrono::hours> now =
|
||||||
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
|
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
|
||||||
std::chrono::sys_time<std::chrono::hours> currentHour =
|
std::chrono::sys_time<std::chrono::hours> currentHour =
|
||||||
(startTime != std::chrono::sys_time<std::chrono::hours> {}) ?
|
(startTime != std::chrono::sys_time<std::chrono::hours> {}) ?
|
||||||
|
|
@ -130,7 +131,8 @@ WarningsProvider::LoadUpdatedFiles(
|
||||||
{
|
{
|
||||||
if (headResponse.status_code == cpr::status::HTTP_OK)
|
if (headResponse.status_code == cpr::status::HTTP_OK)
|
||||||
{
|
{
|
||||||
bool updated = p->UpdateFileRecord(headResponse, filename);
|
const bool updated =
|
||||||
|
p->UpdateFileRecord(headResponse, filename);
|
||||||
|
|
||||||
if (updated)
|
if (updated)
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +175,7 @@ WarningsProvider::LoadUpdatedFiles(
|
||||||
logger_->debug("Loading file: {}", filename);
|
logger_->debug("Loading file: {}", filename);
|
||||||
|
|
||||||
// Load file
|
// Load file
|
||||||
std::shared_ptr<awips::TextProductFile> textProductFile {
|
const std::shared_ptr<awips::TextProductFile> textProductFile {
|
||||||
std::make_shared<awips::TextProductFile>()};
|
std::make_shared<awips::TextProductFile>()};
|
||||||
std::istringstream responseBody {response.text};
|
std::istringstream responseBody {response.text};
|
||||||
if (textProductFile->LoadData(filename, responseBody))
|
if (textProductFile->LoadData(filename, responseBody))
|
||||||
|
|
@ -218,7 +220,7 @@ bool WarningsProvider::Impl::UpdateFileRecord(const cpr::Response& response,
|
||||||
lastModified = lastModifiedIt->second;
|
lastModified = lastModifiedIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock lock(filesMutex_);
|
const std::unique_lock lock(filesMutex_);
|
||||||
|
|
||||||
auto it = files_.find(filename);
|
auto it = files_.find(filename);
|
||||||
if (it != files_.cend())
|
if (it != files_.cend())
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@
|
||||||
# include <date/date.h>
|
# include <date/date.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx::util
|
||||||
{
|
|
||||||
namespace util
|
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string logPrefix_ = "scwx::util::time";
|
static const std::string logPrefix_ = "scwx::util::time";
|
||||||
|
|
@ -48,6 +46,7 @@ std::chrono::system_clock::time_point TimePoint(uint32_t modifiedJulianDate,
|
||||||
using sys_days = time_point<system_clock, days>;
|
using sys_days = time_point<system_clock, days>;
|
||||||
constexpr auto epoch = sys_days {1969y / December / 31d};
|
constexpr auto epoch = sys_days {1969y / December / 31d};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers): literals are used
|
||||||
return epoch + (modifiedJulianDate * 24h) +
|
return epoch + (modifiedJulianDate * 24h) +
|
||||||
std::chrono::milliseconds {milliseconds};
|
std::chrono::milliseconds {milliseconds};
|
||||||
}
|
}
|
||||||
|
|
@ -154,5 +153,4 @@ template std::optional<std::chrono::sys_time<std::chrono::seconds>>
|
||||||
TryParseDateTime<std::chrono::seconds>(const std::string& dateTimeFormat,
|
TryParseDateTime<std::chrono::seconds>(const std::string& dateTimeFormat,
|
||||||
const std::string& str);
|
const std::string& str);
|
||||||
|
|
||||||
} // namespace util
|
} // namespace scwx::util
|
||||||
} // namespace scwx
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue