From dc7e980a05c7f17e139b53f7c35833de04b6abfb Mon Sep 17 00:00:00 2001 From: a-kenji Date: Thu, 18 Feb 2021 14:16:38 +0100 Subject: [PATCH 1/5] fix(clippy): unneccessary `>= y + 1` or `x - 1 >=` --- src/client/tab.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/tab.rs b/src/client/tab.rs index 174948c1..7c721324 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1,4 +1,5 @@ -//! `Tab`s holds multiple panes. It tracks their coordinates (x/y) and size, as well as how they should be resized +//! `Tab`s holds multiple panes. It tracks their coordinates (x/y) and size, +//! as well as how they should be resized use crate::common::{AppInstruction, SenderWithContext}; use crate::panes::{PaneId, PositionAndSize, TerminalPane}; @@ -296,9 +297,8 @@ impl Tab { * terminal_to_check.columns(); let terminal_can_be_split = terminal_to_check.columns() >= MIN_TERMINAL_WIDTH && terminal_to_check.rows() >= MIN_TERMINAL_HEIGHT - && ((terminal_to_check.columns() >= terminal_to_check.min_width() * 2 + 1) - || (terminal_to_check.rows() - >= terminal_to_check.min_height() * 2 + 1)); + && ((terminal_to_check.columns() > terminal_to_check.min_width() * 2) + || (terminal_to_check.rows() > terminal_to_check.min_height() * 2)); if terminal_can_be_split && terminal_size > current_largest_terminal_size { (terminal_size, Some(*id_of_terminal_to_check)) } else { @@ -321,7 +321,7 @@ impl Tab { y: terminal_to_split.y(), }; if terminal_to_split.rows() * CURSOR_HEIGHT_WIDTH_RATIO > terminal_to_split.columns() - && terminal_to_split.rows() >= terminal_to_split.min_height() * 2 + 1 + && terminal_to_split.rows() > terminal_to_split.min_height() * 2 { // FIXME: This could use a second look if let PaneId::Terminal(term_pid) = pid { @@ -343,7 +343,7 @@ impl Tab { } self.active_terminal = Some(pid); } - } else if terminal_to_split.columns() >= terminal_to_split.min_width() * 2 + 1 { + } else if terminal_to_split.columns() > terminal_to_split.min_width() * 2 { // FIXME: This could use a second look if let PaneId::Terminal(term_pid) = pid { let (left_winsize, right_winsize) = split_vertically_with_gap(&terminal_ws); From 12571a115d60050274b85648abf86ff11abfbb5c Mon Sep 17 00:00:00 2001 From: a-kenji Date: Thu, 18 Feb 2021 15:08:13 +0100 Subject: [PATCH 2/5] fix(clippy): useless use of `format!` --- src/common/input/handler.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 14e7876a..4d1e4f44 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -283,34 +283,34 @@ pub fn get_help(mode: InputMode) -> Help { let mut keybinds: Vec<(String, String)> = vec![]; match mode { InputMode::Normal | InputMode::Command => { - keybinds.push((format!("p"), format!("PANE"))); - keybinds.push((format!("t"), format!("TAB"))); - keybinds.push((format!("r"), format!("RESIZE"))); - keybinds.push((format!("s"), format!("SCROLL"))); + keybinds.push(("p".to_string(), "PANE".to_string())); + keybinds.push(("t".to_string(), "TAB".to_string())); + keybinds.push(("r".to_string(), "RESIZE".to_string())); + keybinds.push(("s".to_string(), "SCROLL".to_string())); } InputMode::Resize => { - keybinds.push((format!("←↓↑→"), format!("Resize"))); + keybinds.push(("←↓↑→".to_string(), "Resize".to_string())); } InputMode::Pane => { - keybinds.push((format!("←↓↑→"), format!("Move focus"))); - keybinds.push((format!("p"), format!("Next"))); - keybinds.push((format!("n"), format!("New"))); - keybinds.push((format!("d"), format!("Split down"))); - keybinds.push((format!("r"), format!("Split right"))); - keybinds.push((format!("x"), format!("Close"))); - keybinds.push((format!("f"), format!("Fullscreen"))); + keybinds.push(("←↓↑→".to_string(), "Move focus".to_string())); + keybinds.push(("p".to_string(), "Next".to_string())); + keybinds.push(("n".to_string(), "New".to_string())); + keybinds.push(("d".to_string(), "Split down".to_string())); + keybinds.push(("r".to_string(), "Split right".to_string())); + keybinds.push(("x".to_string(), "Close".to_string())); + keybinds.push(("f".to_string(), "Fullscreen".to_string())); } InputMode::Tab => { - keybinds.push((format!("←↓↑→"), format!("Move focus"))); - keybinds.push((format!("n"), format!("New"))); - keybinds.push((format!("x"), format!("Close"))); + keybinds.push(("←↓↑→".to_string(), "Move focus".to_string())); + keybinds.push(("n".to_string(), "New".to_string())); + keybinds.push(("x".to_string(), "Close".to_string())); } InputMode::Scroll => { - keybinds.push((format!("↓↑"), format!("Scroll"))); + keybinds.push(("↓↑".to_string(), "Scroll".to_string())); } } - keybinds.push((format!("ESC"), format!("BACK"))); - keybinds.push((format!("q"), format!("QUIT"))); + keybinds.push(("ESC".to_string(), "BACK".to_string())); + keybinds.push(("q".to_string(), "QUIT".to_string())); Help { mode, keybinds } } From b9eb6c5b990b22468f138336ea857836c713e4c9 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Thu, 18 Feb 2021 15:11:28 +0100 Subject: [PATCH 3/5] allow(clippy): single_match for signal handler Should get more matches in the future. --- src/common/os_input_output.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 132ff46d..26a7d497 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -83,6 +83,7 @@ fn handle_command_exit(mut child: Child) { for signal in signals.pending() { // FIXME: We need to handle more signals here! + #[allow(clippy::single_match)] match signal { signal_hook::SIGINT => { child.kill().unwrap(); From fc1a956040b2fcebe2e9192891a28b515b9bcff9 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Thu, 18 Feb 2021 21:22:44 +0100 Subject: [PATCH 4/5] fix(clippy): unneeded `return` statement --- src/client/tab.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/client/tab.rs b/src/client/tab.rs index 7c721324..a203b2ba 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1433,7 +1433,7 @@ impl Tab { p.columns() > increase_by && p.columns() - increase_by >= p.min_width() }); } else { - return false; + false } } fn can_increase_pane_and_surroundings_left( @@ -1455,7 +1455,7 @@ impl Tab { p.columns() > increase_by && p.columns() - increase_by >= p.min_width() }); } else { - return false; + false } } fn can_increase_pane_and_surroundings_down( @@ -1477,7 +1477,7 @@ impl Tab { p.rows() > increase_by && p.rows() - increase_by >= p.min_height() }); } else { - return false; + false } } fn can_increase_pane_and_surroundings_up(&self, pane_id: &PaneId, increase_by: usize) -> bool { @@ -1495,7 +1495,7 @@ impl Tab { p.rows() > increase_by && p.rows() - increase_by >= p.min_height() }); } else { - return false; + false } } fn can_reduce_pane_and_surroundings_right(&self, pane_id: &PaneId, reduce_by: usize) -> bool { @@ -1514,7 +1514,7 @@ impl Tab { .unwrap_or(true) // no max width, increase to your heart's content }); } else { - return false; + false } } fn can_reduce_pane_and_surroundings_left(&self, pane_id: &PaneId, reduce_by: usize) -> bool { @@ -1533,7 +1533,7 @@ impl Tab { .unwrap_or(true) // no max width, increase to your heart's content }); } else { - return false; + false } } fn can_reduce_pane_and_surroundings_down(&self, pane_id: &PaneId, reduce_by: usize) -> bool { @@ -1552,7 +1552,7 @@ impl Tab { .unwrap_or(true) // no max height, increase to your heart's content }); } else { - return false; + false } } fn can_reduce_pane_and_surroundings_up(&self, pane_id: &PaneId, reduce_by: usize) -> bool { @@ -1571,7 +1571,7 @@ impl Tab { .unwrap_or(true) // no max height, increase to your heart's content }); } else { - return false; + false } } pub fn resize_right(&mut self) { From 6bb419661e2d324bcafe7bb2b84608e0c98adf4c Mon Sep 17 00:00:00 2001 From: a-kenji Date: Thu, 18 Feb 2021 21:46:16 +0100 Subject: [PATCH 5/5] fix(clippy): use of `unwrap_or` followed by a fn use of `unwrap_or` followed by a function call --- src/common/input/keybinds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs index 7197d2de..151d3495 100644 --- a/src/common/input/keybinds.rs +++ b/src/common/input/keybinds.rs @@ -172,7 +172,7 @@ pub fn key_to_actions( // FIXME in command mode, unbound keystrokes should probably do nothing instead of // writing to the terminal. Will be easier to implement after a big refactor of the // input system (@categorille) - .unwrap_or(vec![Action::Write(input)]) + .unwrap_or_else(|| vec![Action::Write(input)]) } else { unreachable!("Unrecognized mode: {:?}", mode); }