fix: sonarcloud warnings (#2815)

* fix: add default case to switch statement

* fix: remove redundant static specifier

* fix: use std::optional.value_or

* fix: make type of variable pointer-to-const

* refactor: move log state into a struct

* refactor: make tr_peerMgr constructor explicit

* fix: make type of variable pointer-to-const

* fix: replace insert with try_emplace

* fix: implicit conversion may lose precision

* fix: use init-statement to reduce variable scope

* chore: mark unused return value with (void)
This commit is contained in:
Charles Kerr
2022-03-25 00:24:04 -05:00
committed by GitHub
parent 0a8cfba3b3
commit b94c6796c8
8 changed files with 55 additions and 55 deletions

View File

@@ -271,8 +271,7 @@ void setForegroundColor(Gtk::CellRendererText* renderer, tr_log_level level)
renderer->property_foreground() = "forestgreen";
break;
case TR_LOG_INFO:
case TR_LOG_OFF:
default:
renderer->property_foreground_set() = false;
break;
}

View File

@@ -849,7 +849,7 @@ Gtk::ComboBox* new_time_combo(Glib::RefPtr<Session> const& core, tr_quark const
return w;
}
static auto get_weekday_string(Glib::Date::Weekday weekday)
auto get_weekday_string(Glib::Date::Weekday weekday)
{
auto date = Glib::Date{};
date.set_time_current();

View File

@@ -180,7 +180,7 @@ std::string getShortStatusString(
}
}
static std::optional<std::string> getErrorString(tr_stat const* st)
std::optional<std::string> getErrorString(tr_stat const* st)
{
switch (st->error)
{
@@ -198,7 +198,7 @@ static std::optional<std::string> getErrorString(tr_stat const* st)
}
}
static auto getActivityString(
auto getActivityString(
tr_torrent const* const tor,
tr_stat const* const st,
double const uploadSpeed_KBps,
@@ -275,16 +275,7 @@ std::string getStatusString(
double const uploadSpeed_KBps,
double const downloadSpeed_KBps)
{
auto status_str = std::string{};
if (auto error_string = getErrorString(st); error_string)
{
status_str = *error_string;
}
else
{
status_str = getActivityString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps);
}
auto status_str = getErrorString(st).value_or(getActivityString(tor, st, uploadSpeed_KBps, downloadSpeed_KBps));
if (st->activity != TR_STATUS_CHECK_WAIT && st->activity != TR_STATUS_CHECK && st->activity != TR_STATUS_DOWNLOAD_WAIT &&
st->activity != TR_STATUS_SEED_WAIT && st->activity != TR_STATUS_STOPPED)