1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

fix: sonarcloud use-init-statement warnings in new code (#2536)

This commit is contained in:
Charles Kerr 2022-01-29 16:26:09 -06:00 committed by GitHub
parent 52f6e80a61
commit 314aa6925d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -211,9 +211,7 @@ void tr_announcerParseHttpAnnounceResponse(tr_announce_response& response, std::
bool Int64(int64_t value, Context const& context) override
{
auto const key = currentKey();
if (key == "interval")
if (auto const key = currentKey(); key == "interval")
{
response_.interval = value;
}
@ -248,9 +246,7 @@ void tr_announcerParseHttpAnnounceResponse(tr_announce_response& response, std::
bool String(std::string_view value, Context const& context) override
{
auto const key = currentKey();
if (key == "failure reason"sv)
if (auto const key = currentKey(); key == "failure reason"sv)
{
response_.errmsg = value;
}
@ -399,8 +395,7 @@ void tr_announcerParseHttpScrapeResponse(tr_scrape_response& response, std::stri
{
BasicHandler::Key(value, context);
auto needle = tr_sha1_digest_t{};
if (depth() == 2 && key(1) == "files"sv && std::size(value) == std::size(needle))
if (auto needle = tr_sha1_digest_t{}; depth() == 2 && key(1) == "files"sv && std::size(value) == std::size(needle))
{
std::copy_n(reinterpret_cast<std::byte const*>(std::data(value)), std::size(value), std::data(needle));
auto const it = std::find_if(