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