diff options
author | Jannik <32144358+mozzieongit@users.noreply.github.com> | 2021-09-24 18:03:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-24 16:03:37 +0000 |
commit | 446ffb88c7b67d61d41be084fa724f84fa055e22 (patch) | |
tree | 244f8a7c0ac262e93c83c2e540e90ba0e02da711 /src/command | |
parent | 2024884f49334e7eaf64adc425da77b773204b42 (diff) |
Resolve clippy warnings (#187)
* refactor: nest or patterns
* refactor: fix clippy lint names
* refactor: remove unnecessary wraps
* style: apply cargo fmt
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/history.rs | 2 | ||||
-rw-r--r-- | src/command/init.rs | 4 | ||||
-rw-r--r-- | src/command/mod.rs | 5 | ||||
-rw-r--r-- | src/command/search.rs | 12 |
4 files changed, 11 insertions, 12 deletions
diff --git a/src/command/history.rs b/src/command/history.rs index 9c792cf02..4606b3040 100644 --- a/src/command/history.rs +++ b/src/command/history.rs @@ -60,7 +60,7 @@ pub enum Cmd { }, } -#[allow(clippy::clippy::cast_sign_loss)] +#[allow(clippy::cast_sign_loss)] pub fn print_list(h: &[History], human: bool, cmd_only: bool) { let mut writer = TabWriter::new(std::io::stdout()).padding(2); diff --git a/src/command/init.rs b/src/command/init.rs index d0f31f345..b6fbe4b35 100644 --- a/src/command/init.rs +++ b/src/command/init.rs @@ -1,4 +1,3 @@ -use eyre::Result; use structopt::StructOpt; #[derive(StructOpt)] @@ -20,11 +19,10 @@ fn init_bash() { } impl Cmd { - pub fn run(&self) -> Result<()> { + pub fn run(&self) { match self { Self::Zsh => init_zsh(), Self::Bash => init_bash(), } - Ok(()) } } diff --git a/src/command/mod.rs b/src/command/mod.rs index 6050c4ebd..f959fc986 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -108,7 +108,10 @@ impl AtuinCmd { Self::Import(import) => import.run(&mut db).await, Self::Server(server) => server.run(&server_settings).await, Self::Stats(stats) => stats.run(&mut db, &client_settings).await, - Self::Init(init) => init.run(), + Self::Init(init) => { + init.run(); + Ok(()) + } Self::Search { cwd, exit, diff --git a/src/command/search.rs b/src/command/search.rs index d3807bcad..00e11f525 100644 --- a/src/command/search.rs +++ b/src/command/search.rs @@ -31,7 +31,7 @@ struct State { } impl State { - #[allow(clippy::clippy::cast_sign_loss)] + #[allow(clippy::cast_sign_loss)] fn durations(&self) -> Vec<(String, String)> { self.results .iter() @@ -179,9 +179,7 @@ async fn key_handler( app: &mut State, ) -> Option<String> { match input { - Key::Esc | Key::Ctrl('c') | Key::Ctrl('d') | Key::Ctrl('g') => { - return Some(String::from("")) - } + Key::Esc | Key::Ctrl('c' | 'd' | 'g') => return Some(String::from("")), Key::Char('\n') => { let i = app.results_state.selected().unwrap_or(0); @@ -241,7 +239,7 @@ async fn key_handler( None } -#[allow(clippy::clippy::cast_possible_truncation)] +#[allow(clippy::cast_possible_truncation)] fn draw<T: Backend>(f: &mut Frame<'_, T>, history_count: i64, app: &mut State) { let chunks = Layout::default() .direction(Direction::Vertical) @@ -312,7 +310,7 @@ fn draw<T: Backend>(f: &mut Frame<'_, T>, history_count: i64, app: &mut State) { // this is a big blob of horrible! clean it up! // for now, it works. But it'd be great if it were more easily readable, and // modular. I'd like to add some more stats and stuff at some point -#[allow(clippy::clippy::cast_possible_truncation)] +#[allow(clippy::cast_possible_truncation)] async fn select_history( query: &[String], search_mode: SearchMode, @@ -350,7 +348,7 @@ async fn select_history( // This is supposed to more-or-less mirror the command line version, so ofc // it is going to have a lot of args -#[allow(clippy::clippy::clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments)] pub async fn run( settings: &Settings, cwd: Option<String>, |