From 938d4bdb5f6dbf76f22b91bf293ea03bc8b3c8b0 Mon Sep 17 00:00:00 2001 From: Sergio Ivanuzzo Date: Tue, 28 Apr 2026 23:44:05 +0200 Subject: [PATCH] Fix clippy collapsible-if code scanning findings --- src/client/types.rs | 10 +++--- src/plugins/dbg_ui/mod.rs | 34 +++++++++---------- .../tui/components/json_navigator/mod.rs | 20 +++++------ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/client/types.rs b/src/client/types.rs index 6c3f602..cdcca82 100644 --- a/src/client/types.rs +++ b/src/client/types.rs @@ -137,11 +137,11 @@ impl OrderedReceiver { self.next = self.buffer.keys().next().copied(); } - if let Some(next) = self.next { - if let Some(entry) = self.buffer.remove(&next) { - self.next = Some(next + 1); - return Ok(entry); - } + if let Some(next) = self.next + && let Some(entry) = self.buffer.remove(&next) + { + self.next = Some(next + 1); + return Ok(entry); } // soft-fail protection diff --git a/src/plugins/dbg_ui/mod.rs b/src/plugins/dbg_ui/mod.rs index 14dcb49..cbf8446 100644 --- a/src/plugins/dbg_ui/mod.rs +++ b/src/plugins/dbg_ui/mod.rs @@ -84,25 +84,25 @@ impl CorePlugin for DbgUI { } loop { - if let Ok(Some(line)) = lines.next_line().await { - if let Ok(idx) = line.trim().parse::() { - if let Some(chosen) = items.get(idx) { - println!("You chose: {}", chosen); + if let Ok(Some(line)) = lines.next_line().await + && let Ok(idx) = line.trim().parse::() + { + if let Some(chosen) = items.get(idx) { + println!("You chose: {}", chosen); - let option = echo_senders.get(&label); - if let Some(sender) = option { - let _ = sender - .send(Echo::Choose(vec![idx])) - .await; - } - - break; - } else { - println!( - "{}", - "Invalid index, try again".bright_red() - ); + let option = echo_senders.get(&label); + if let Some(sender) = option { + let _ = sender + .send(Echo::Choose(vec![idx])) + .await; } + + break; + } else { + println!( + "{}", + "Invalid index, try again".bright_red() + ); } } } diff --git a/src/plugins/tui/components/json_navigator/mod.rs b/src/plugins/tui/components/json_navigator/mod.rs index e20aa9f..98df2c1 100644 --- a/src/plugins/tui/components/json_navigator/mod.rs +++ b/src/plugins/tui/components/json_navigator/mod.rs @@ -287,21 +287,21 @@ impl EventHandler for JsonNavigator { match event.code { KeyCode::Up => { - if self.nav_active { + if self.nav_active && { moved = self.cursor.step_backward().is_some(); - if !moved { - self.json_scroll = self.json_scroll.saturating_sub(1); - self.hex_scroll = self.hex_scroll.saturating_sub(1); - } + !moved + } { + self.json_scroll = self.json_scroll.saturating_sub(1); + self.hex_scroll = self.hex_scroll.saturating_sub(1); } } KeyCode::Down => { - if self.nav_active { + if self.nav_active && { moved = self.cursor.step_forward().is_some(); - if !moved { - self.json_scroll = self.json_scroll.saturating_add(1); - self.hex_scroll = self.hex_scroll.saturating_add(1); - } + !moved + } { + self.json_scroll = self.json_scroll.saturating_add(1); + self.hex_scroll = self.hex_scroll.saturating_add(1); } } KeyCode::Left => {