Clippy suggestions

This commit is contained in:
Marco De Araujo 2026-01-19 06:28:25 -04:00
parent 00cb8f7a9b
commit c48a37d56a
5 changed files with 22 additions and 22 deletions

View file

@ -55,7 +55,7 @@ impl HeartbeatResponse {
for (monitor_id_str, heartbeats) in &self.heartbeat_list_raw {
let monitor_id = monitor_id_str
.parse::<u64>()
.with_context(|| format!("{}", t("invalid-monitor-id")))?;
.with_context(|| t("invalid-monitor-id").to_string())?;
self.monitors.push(MonitorHeartbeats {
monitor_id,
@ -77,11 +77,11 @@ impl HeartbeatResponse {
let monitor_id = parts[0]
.parse::<u64>()
.with_context(|| format!("{}", t("invalid-monitor-id")))?;
.with_context(|| t("invalid-monitor-id").to_string())?;
let period_hours = parts[1]
.parse::<u32>()
.with_context(|| format!("{}", t("invalid-period-hours")))?;
.with_context(|| t("invalid-period-hours").to_string())?;
self.uptime_data.push(UptimeData {
monitor_id,

View file

@ -34,7 +34,7 @@ pub fn t(key: &str) -> String {
}
}
let result = LOCALES.lookup(&*get_system_locale(), key);
let result = LOCALES.lookup(get_system_locale(), key);
let mut cache_write = cache.write().unwrap();
@ -51,5 +51,5 @@ pub fn t_with_args(key: &str, args: &HashMap<&'static str, String>) -> String {
for (key, value) in args {
map.insert(Cow::Borrowed(*key), FluentValue::from(value));
}
LOCALES.lookup_with_args(&get_system_locale(), key, &map)
LOCALES.lookup_with_args(get_system_locale(), key, &map)
}

View file

@ -159,7 +159,7 @@ impl App {
let seconds_until_update = self
.update_interval
.checked_sub(self.last_update.elapsed())
.map(|d| d.as_secs() as u64)
.map(|d| d.as_secs())
.unwrap_or(30);
render_footer(frame, chunks[2], seconds_until_update);
@ -198,8 +198,9 @@ impl App {
fn handle_events(&mut self) -> io::Result<()> {
let timeout = Duration::from_secs(1);
if event::poll(timeout)? {
if let Event::Key(key) = event::read()? {
if event::poll(timeout)?
&& let Event::Key(key) = event::read()?
{
if key.kind == KeyEventKind::Release {
return Ok(());
}
@ -213,7 +214,6 @@ impl App {
_ => {}
}
}
}
Ok(())
}

View file

@ -38,7 +38,7 @@ pub fn render_monitor_list(main_frame: &mut Frame, area: Rect, state: &mut Dashb
let mut lines_skipped = 0;
let half = state.get_total_lenght().saturating_div(2);
for (_i, group) in state.groups.iter().enumerate() {
for group in state.groups.iter() {
let group_height = group.monitors.len() + BORDER_LINES_VIEW;
if lines_skipped + group_height <= scroll_pos {
@ -103,7 +103,7 @@ fn render_group(frame: &mut Frame, area: Rect, group: &GroupViewState, is_first_
fn render_monitor_table(
frame: &mut Frame,
area: Rect,
monitors: &Vec<MonitorViewState>,
monitors: &[MonitorViewState],
is_first_half: bool,
) {
let max_items = area.height as usize;

View file

@ -120,7 +120,7 @@ fn add_monitor_view_state(group: UnifiedGroupData) -> Vec<MonitorViewState> {
.monitors
.into_par_iter()
.map(|monitor| {
let status_history = get_status_history(&monitor.heartbeats);
let status_history = get_status_history(monitor.heartbeats);
let status = match monitor.heartbeats.last().map(|h| h.status) {
Some(1) => MonitorStatus::Up,