summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDany Marcoux <dmarcoux@posteo.de>2022-05-23 17:04:25 +0200
committerGitHub <noreply@github.com>2022-05-23 11:04:25 -0400
commitd8d95d572a1723bda4bd32b9fa17ce6dd6a22bb6 (patch)
tree7f7b255585132c67aa7c161befc98eb380e5abb0 /src
parent1fc9ad1f52f417d74de05f9c7c5a56d329d19561 (diff)
Add GitHub workflow for Clippy (#173)
* Add GitHub workflow for Clippy Closes #158 * Fix errors found by clippy::needless-borrow https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow * Fix errors found by clippy::collapsible-else-if https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if * Fix error found by clippy::single-match https://rust-lang.github.io/rust-clippy/master/index.html#single_match
Diffstat (limited to 'src')
-rw-r--r--src/commands/open_file.rs23
-rw-r--r--src/commands/zoxide.rs24
-rw-r--r--src/key_command/impl_appexecute.rs2
3 files changed, 21 insertions, 28 deletions
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 48c0d0b..24acae1 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -72,11 +72,11 @@ where
S: AsRef<std::ffi::OsStr>,
{
if option.get_fork() {
- let (child_id, handle) = fork_execute(&option, files, context.clone_event_tx())?;
+ let (child_id, handle) = fork_execute(option, files, context.clone_event_tx())?;
context.worker_context_mut().push_child(child_id, handle);
} else {
backend.terminal_drop();
- execute_and_wait(&option, files)?;
+ execute_and_wait(option, files)?;
backend.terminal_restore()?;
}
Ok(())
@@ -139,20 +139,17 @@ where
}
Ok(n) => {
let option = &options[n];
- open_with_entry(context, backend, option, &files)?;
+ open_with_entry(context, backend, option, files)?;
}
Err(_) => {
let mut args_iter = user_input.split_whitespace();
- match args_iter.next() {
- Some(cmd) => {
- backend.terminal_drop();
- let mut option = AppMimetypeEntry::new(String::from(cmd));
- option.args(args_iter);
- let res = execute_and_wait(&option, files);
- backend.terminal_restore()?;
- res?
- }
- None => {}
+ if let Some(cmd) = args_iter.next() {
+ backend.terminal_drop();
+ let mut option = AppMimetypeEntry::new(String::from(cmd));
+ option.args(args_iter);
+ let res = execute_and_wait(&option, files);
+ backend.terminal_restore()?;
+ res?
}
}
}
diff --git a/src/commands/zoxide.rs b/src/commands/zoxide.rs
index 1abe9f2..9ee1bf6 100644
--- a/src/commands/zoxide.rs
+++ b/src/commands/zoxide.rs
@@ -27,14 +27,12 @@ pub fn zoxide_query(context: &mut AppContext, args: &str) -> JoshutoResult {
context
.message_queue_mut()
.push_info(format!("z {:?}", zoxide_path));
- change_directory::change_directory(context, &path)?;
- }
- } else {
- if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
- context
- .message_queue_mut()
- .push_error(zoxide_str.to_string());
+ change_directory::change_directory(context, path)?;
}
+ } else if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
+ context
+ .message_queue_mut()
+ .push_error(zoxide_str.to_string());
}
Ok(())
}
@@ -65,14 +63,12 @@ pub fn zoxide_query_interactive(
context
.message_queue_mut()
.push_info(format!("zi {:?}", zoxide_path));
- change_directory::change_directory(context, &path)?;
- }
- } else {
- if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
- context
- .message_queue_mut()
- .push_error(zoxide_str.to_string());
+ change_directory::change_directory(context, path)?;
}
+ } else if let Ok(zoxide_str) = std::str::from_utf8(&zoxide_output.stderr) {
+ context
+ .message_queue_mut()
+ .push_error(zoxide_str.to_string());
}
Ok(())
}
diff --git a/src/key_command/impl_appexecute.rs b/src/key_command/impl_appexecute.rs
index 0a9725c..2e5da84 100644
--- a/src/key_command/impl_appexecute.rs
+++ b/src/key_command/impl_appexecute.rs
@@ -106,7 +106,7 @@ impl AppExecute for Command {
Self::SearchFzf => search_fzf::search_fzf(context, backend),
Self::SubdirFzf => subdir_fzf::subdir_fzf(context, backend),
- Self::Zoxide(arg) => zoxide::zoxide_query(context, &arg),
+ Self::Zoxide(arg) => zoxide::zoxide_query(context, arg),
Self::ZoxideInteractive => zoxide::zoxide_query_interactive(context, backend),
}
}