From 0a0db41a2c6695d91c4c648fcf3083c6cdb12f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20P=C3=A9ron?= Date: Sat, 7 Dec 2024 00:18:18 +0100 Subject: [PATCH 1/4] chore(clippy): fix clippy warnings --- src/uucore/src/lib/features/backup_control.rs | 19 ++++++++----------- src/uucore/src/lib/features/proc_info.rs | 9 +++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/uucore/src/lib/features/backup_control.rs b/src/uucore/src/lib/features/backup_control.rs index 4b4f7aa93..591f57f95 100644 --- a/src/uucore/src/lib/features/backup_control.rs +++ b/src/uucore/src/lib/features/backup_control.rs @@ -667,17 +667,14 @@ mod tests { #[test] fn test_numbered_backup_path() { - assert_eq!(numbered_backup_path(&Path::new("")), PathBuf::from(".~1~")); + assert_eq!(numbered_backup_path(Path::new("")), PathBuf::from(".~1~")); + assert_eq!(numbered_backup_path(Path::new("/")), PathBuf::from("/.~1~")); assert_eq!( - numbered_backup_path(&Path::new("/")), - PathBuf::from("/.~1~") - ); - assert_eq!( - numbered_backup_path(&Path::new("/hello/world")), + numbered_backup_path(Path::new("/hello/world")), PathBuf::from("/hello/world.~1~") ); assert_eq!( - numbered_backup_path(&Path::new("/hello/world/")), + numbered_backup_path(Path::new("/hello/world/")), PathBuf::from("/hello/world.~1~") ); } @@ -685,19 +682,19 @@ mod tests { #[test] fn test_simple_backup_path() { assert_eq!( - simple_backup_path(&Path::new(""), ".bak"), + simple_backup_path(Path::new(""), ".bak"), PathBuf::from(".bak") ); assert_eq!( - simple_backup_path(&Path::new("/"), ".bak"), + simple_backup_path(Path::new("/"), ".bak"), PathBuf::from("/.bak") ); assert_eq!( - simple_backup_path(&Path::new("/hello/world"), ".bak"), + simple_backup_path(Path::new("/hello/world"), ".bak"), PathBuf::from("/hello/world.bak") ); assert_eq!( - simple_backup_path(&Path::new("/hello/world/"), ".bak"), + simple_backup_path(Path::new("/hello/world/"), ".bak"), PathBuf::from("/hello/world.bak") ); } diff --git a/src/uucore/src/lib/features/proc_info.rs b/src/uucore/src/lib/features/proc_info.rs index 7c812ec2a..af5d498d2 100644 --- a/src/uucore/src/lib/features/proc_info.rs +++ b/src/uucore/src/lib/features/proc_info.rs @@ -19,6 +19,15 @@ //! `snice` (TBD) //! +// This file is currently flagged as dead code, because it isn't used anywhere +// in the codebase. It may be useful in the future though, so we decide to keep +// it. +// The code was originally written in procps +// (https://github.com/uutils/procps/blob/main/src/uu/pgrep/src/process.rs) +// but was eventually moved here. +// See https://github.com/uutils/coreutils/pull/6932 for discussion. +#![allow(dead_code)] + use crate::features::tty::Teletype; use std::hash::Hash; use std::{ From 50271381c49df659881e19aca7667132eebb7aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20P=C3=A9ron?= Date: Fri, 6 Dec 2024 21:31:24 +0100 Subject: [PATCH 2/4] fix cargo-deny-action job --- deny.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/deny.toml b/deny.toml index d64a2d33a..79bfe926e 100644 --- a/deny.toml +++ b/deny.toml @@ -22,7 +22,6 @@ allow = [ "Apache-2.0", "ISC", "BSD-2-Clause", - "BSD-2-Clause-FreeBSD", "BSD-3-Clause", "BSL-1.0", "CC0-1.0", From e8141d33607d39367c6e1830665a80ff6bb371f3 Mon Sep 17 00:00:00 2001 From: Dorian Peron Date: Sun, 29 Dec 2024 04:31:02 +0100 Subject: [PATCH 3/4] Add `--tests` to CICD clippy call --- .github/workflows/code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 814da316a..c4a166493 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -112,7 +112,7 @@ jobs: fault_type="${{ steps.vars.outputs.FAULT_TYPE }}" fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]') # * convert any warnings to GHA UI annotations; ref: - S=$(cargo clippy --all-targets --features ${{ matrix.job.features }} -pcoreutils -- ${CLIPPY_FLAGS} -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } + S=$(cargo clippy --all-targets --features ${{ matrix.job.features }} --tests -pcoreutils -- ${CLIPPY_FLAGS} -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; } if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi style_spellcheck: From 48eb8d870356ebb60ce1dcf32774373a5f740b59 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 29 Dec 2024 10:20:34 +0100 Subject: [PATCH 4/4] Add procps to the spell ignore list --- src/uucore/src/lib/features/proc_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/proc_info.rs b/src/uucore/src/lib/features/proc_info.rs index af5d498d2..f40847c1d 100644 --- a/src/uucore/src/lib/features/proc_info.rs +++ b/src/uucore/src/lib/features/proc_info.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore exitstatus cmdline kworker pgrep pwait snice +// spell-checker:ignore exitstatus cmdline kworker pgrep pwait snice procps //! Set of functions to manage IDs //!