From b003d55fe11e13e48c94e39aed902b946bbec9b1 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 26 Dec 2019 17:04:29 -0600 Subject: [PATCH] refactor/polish ~ fix `cargo clippy` complaints (collapse if-if) --- src/ls/ls.rs | 6 ++---- src/mv/mv.rs | 8 +++----- src/nohup/nohup.rs | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/ls/ls.rs b/src/ls/ls.rs index cb9d2bfe1..f66698d92 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -277,10 +277,8 @@ fn max(lhs: usize, rhs: usize) -> usize { fn should_display(entry: &DirEntry, options: &getopts::Matches) -> bool { let ffi_name = entry.file_name(); let name = ffi_name.to_string_lossy(); - if !options.opt_present("a") && !options.opt_present("A") { - if name.starts_with('.') { - return false; - } + if !options.opt_present("a") && !options.opt_present("A") && name.starts_with('.') { + return false; } if options.opt_present("B") && name.ends_with('~') { return false; diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 4c99f77ad..331c15ed1 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -359,11 +359,9 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> { fs::rename(to, p)?; } - if b.update { - if fs::metadata(from)?.modified()? <= fs::metadata(to)?.modified()? - { - return Ok(()); - } + if b.update && fs::metadata(from)?.modified()? <= fs::metadata(to)?.modified()? + { + return Ok(()); } } diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index d9d7de6a3..90dd28f6e 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -105,10 +105,8 @@ fn replace_fds() { } } - if is_stderr_interactive() { - if unsafe { dup2(1, 2) } != 2 { - crash!(2, "Cannot replace STDERR: {}", Error::last_os_error()) - } + if is_stderr_interactive() && unsafe { dup2(1, 2) } != 2 { + crash!(2, "Cannot replace STDERR: {}", Error::last_os_error()) } }