From 7b700ccae2d44ef8de1bd192badc79856f97cdd3 Mon Sep 17 00:00:00 2001 From: Gabriele Belluardo Date: Tue, 17 Jun 2025 11:02:25 +0200 Subject: [PATCH 1/3] fix(clippy): silent more rules `--all-targets --all-features` arguments --- src/uu/chroot/src/chroot.rs | 10 +++++----- src/uu/cp/src/cp.rs | 5 ++--- src/uu/id/src/id.rs | 4 ++-- src/uu/stty/src/stty.rs | 3 +-- src/uu/sync/src/sync.rs | 3 +-- src/uu/uptime/src/uptime.rs | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 2db68d6e9..ffa921161 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -95,12 +95,12 @@ fn parse_group_list(list_str: &str) -> Result, ChrootError> { if name.is_empty() { // --groups="," continue; - } else { - // --groups=", " - // chroot: invalid group ' ' - show!(ChrootError::InvalidGroup(name.to_string())); - err = true; } + + // --groups=", " + // chroot: invalid group ' ' + show!(ChrootError::InvalidGroup(name.to_string())); + err = true; } else { // TODO Figure out a better condition here. if trimmed_name.starts_with(char::is_numeric) diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index b078063ea..9cb26c221 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -2664,9 +2664,8 @@ fn handle_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; if is_explicit_no_preserve_mode { return MODE_RW_UGO; - } else { - return org_mode & S_IRWXUGO; - }; + } + return org_mode & S_IRWXUGO; } } diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 0b74e53fd..da2f3a7c5 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -217,9 +217,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { set_exit_code(1); if i + 1 >= users.len() { break; - } else { - continue; } + + continue; } } } else { diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index a7356d68b..d1df40d6d 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -916,9 +916,8 @@ fn string_to_control_char(s: &str) -> Result { if let Some(val) = ascii_num { if val > 255 { return Err(ControlCharMappingError::IntOutOfRange(s.to_string())); - } else { - return Ok(val as u8); } + return Ok(val as u8); } // try to parse ^ or just let mut chars = s.chars(); diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index f4f4218e5..1365f41aa 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -143,9 +143,8 @@ mod platform { get_message("sync-error-find-next-volume"), )), }; - } else { - volumes.push(String::from_wide_null(&name)); } + volumes.push(String::from_wide_null(&name)); } } diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 142bf1a7c..c3b97dcb1 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -242,7 +242,7 @@ fn process_utmpx(file: Option<&OsString>) -> (Option, usize) { boot_time = Some(dt.unix_timestamp() as time_t); } } - _ => continue, + _ => (), } } (boot_time, nusers) From ff40cb8b09edf21d2ea6504e0542b61e9458d8a3 Mon Sep 17 00:00:00 2001 From: Gabriele Belluardo Date: Tue, 17 Jun 2025 21:36:59 +0200 Subject: [PATCH 2/3] fix(clippy): allow inefficient_to_string lint in test --- src/uu/head/src/parse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index 2a057e233..ed1345d16 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -152,7 +152,7 @@ mod tests { } fn obsolete_result(src: &[&str]) -> Option, ParseError>> { - Some(Ok(src.iter().map(|s| (*s).to_string()).collect())) + Some(Ok(src.iter().map(|&s| s.to_string()).collect())) } #[test] From 8c69980c9556cbb4d831e121de97c73a0bfea625 Mon Sep 17 00:00:00 2001 From: Gabriele Belluardo Date: Fri, 20 Jun 2025 15:18:11 +0200 Subject: [PATCH 3/3] chore(cp): simplify return statement in handle_no_preserve_mode function --- Cargo.toml | 1 - src/uu/cp/src/cp.rs | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8508a6b34..9683e1b7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -657,7 +657,6 @@ needless_pass_by_value = "allow" # 16 float_cmp = "allow" # 12 items_after_statements = "allow" # 11 return_self_not_must_use = "allow" # 8 -redundant_else = "allow" # 6 needless_continue = "allow" # 6 inline_always = "allow" # 6 fn_params_excessive_bools = "allow" # 6 diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 9cb26c221..7cf409ff2 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -2662,10 +2662,11 @@ fn handle_no_preserve_mode(options: &Options, org_mode: u32) -> u32 { const MODE_RW_UGO: u32 = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) as u32; const S_IRWXUGO: u32 = (S_IRWXU | S_IRWXG | S_IRWXO) as u32; - if is_explicit_no_preserve_mode { - return MODE_RW_UGO; - } - return org_mode & S_IRWXUGO; + return if is_explicit_no_preserve_mode { + MODE_RW_UGO + } else { + org_mode & S_IRWXUGO + }; } }