Skip to content

Commit f20dcee

Browse files
committed
-D rust clippy very fucking pretty
1 parent 63bcad8 commit f20dcee

5 files changed

Lines changed: 31 additions & 24 deletions

File tree

crates/tui/src/app.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ impl App {
240240
fn render_frame(&mut self, f: &mut Frame, theme: &Theme) {
241241
let area = f.area();
242242

243-
if self.sftp_session_id.is_some() && matches!(self.mode, AppMode::Sftp) {}
244243
if let Some(idx) = self.active_session {
245244
if let Some(s) = self.sessions.get(idx) {
246245
if matches!(s.status, SessionStatus::Active | SessionStatus::Connecting)
@@ -465,7 +464,7 @@ impl App {
465464
if pos < line_str.len() {
466465
spans.push(Span::raw(line_str[pos..].to_string()));
467466
}
468-
lines[li as usize] = Line::from(spans);
467+
lines[li] = Line::from(spans);
469468
}
470469
}
471470
let (cursor_col, cursor_row) = self.sessions[idx].view.cursor();
@@ -1482,22 +1481,22 @@ impl App {
14821481
return;
14831482
}
14841483

1485-
if !self.sessions.is_empty() && !matches!(self.mode, AppMode::Prompt { .. }) {
1486-
if k.code == KeyCode::Tab
1487-
&& !k.modifiers.contains(KeyModifiers::CONTROL)
1488-
&& !self.capture_mode
1489-
{
1490-
self.focus = Focus::Terminal;
1484+
if !self.sessions.is_empty()
1485+
&& !matches!(self.mode, AppMode::Prompt { .. })
1486+
&& k.code == KeyCode::Tab
1487+
&& !k.modifiers.contains(KeyModifiers::CONTROL)
1488+
&& !self.capture_mode
1489+
{
1490+
self.focus = Focus::Terminal;
14911491

1492-
let first = self
1493-
.sessions
1494-
.iter()
1495-
.position(|s| s.is_active() || s.disconnected().is_some())
1496-
.or(self.active_session);
1497-
if let Some(i) = first {
1498-
self.active_session = Some(i);
1499-
return;
1500-
}
1492+
let first = self
1493+
.sessions
1494+
.iter()
1495+
.position(|s| s.is_active() || s.disconnected().is_some())
1496+
.or(self.active_session);
1497+
if let Some(i) = first {
1498+
self.active_session = Some(i);
1499+
return;
15011500
}
15021501
}
15031502

@@ -1883,7 +1882,7 @@ impl App {
18831882
}
18841883
(KeyCode::Enter, _) => {
18851884
if let Some(h) = self.selected_host().cloned() {
1886-
let _ = cmd_tx.send(Cmd::Connect { host: h });
1885+
let _ = cmd_tx.send(Cmd::Connect { host: Box::new(h) });
18871886
}
18881887
}
18891888
(KeyCode::F(2), _) => {
@@ -3891,7 +3890,7 @@ fn format_network_speed(kbs: f32) -> String {
38913890
} else if kbs >= 1.0 {
38923891
format!("{:.0}KB/s", kbs)
38933892
} else {
3894-
format!("0B/s")
3893+
"0B/s".to_string()
38953894
}
38963895
}
38973896

@@ -4303,7 +4302,7 @@ fn key_to_bytes(k: KeyEvent) -> Vec<u8> {
43034302

43044303
#[derive(Debug)]
43054304
pub enum Cmd {
4306-
Connect { host: Host },
4305+
Connect { host: Box<Host> },
43074306
CancelConnect,
43084307
OpenSftp { session_id: SessionId },
43094308
SftpEnter,

crates/tui/src/pty_render.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl TerminalView {
5050

5151
pub fn cursor(&self) -> (u16, u16) {
5252
let (r, c) = self.parser.screen().cursor_position();
53-
(c as u16, r as u16)
53+
(c, r)
5454
}
5555

5656
pub fn scroll_up(&mut self, n: u16) {
@@ -101,7 +101,7 @@ impl TerminalView {
101101
let mut out = Vec::with_capacity(self.rows as usize);
102102
for y in want_from..want_to.min(total) {
103103
let mut s = String::new();
104-
for x in 0..self.cols as u16 {
104+
for x in 0..self.cols {
105105
if let Some(cell) = screen.cell(y as u16, x) {
106106
s.push(cell.contents().chars().next().unwrap_or(' '));
107107
} else {

crates/tui/src/settings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ pub fn draw_settings(
511511
let phase = animation_phase(3000);
512512
let nick_color = cycle_color(theme.accent2, theme.accent, theme.good, phase);
513513

514-
let raw_lines = vec![
514+
let raw_lines = [
515515
format!("Made with {} by project-fe.dev", '\u{2665}'),
516516
"Main developer: c0redev".into(),
517517
"Website: unitdev.run".into(),
@@ -606,7 +606,7 @@ pub fn draw_settings(
606606
let val = if editing {
607607
format!(" {}_", s.edit_buf)
608608
} else {
609-
format!("{}", f.value)
609+
f.value.to_string()
610610
};
611611

612612
let val_color = if editing {

crates/tui/src/state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ pub struct SearchState {
8080
pub active: bool,
8181
}
8282

83+
impl Default for SearchState {
84+
fn default() -> Self {
85+
Self::new()
86+
}
87+
}
88+
8389
impl SearchState {
8490
pub fn new() -> Self {
8591
Self {

crates/tui/src/view.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use ratatui::widgets::{
1010
use ratatui::Frame;
1111
use std::collections::{HashMap, HashSet};
1212

13+
#[allow(clippy::too_many_arguments)]
1314
pub fn draw_host_list(
1415
f: &mut Frame,
1516
area: Rect,
@@ -145,6 +146,7 @@ pub fn draw_host_list(
145146
f.render_stateful_widget(list, area, state);
146147
}
147148

149+
#[allow(clippy::too_many_arguments)]
148150
pub fn draw_terminal(
149151
f: &mut Frame,
150152
area: Rect,

0 commit comments

Comments
 (0)