From 1c0d036380077d7adaa25a7eb91a082eea14c08f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 15:22:01 +0100 Subject: [PATCH 1/6] Remove unused imports --- src/uu/sed/src/sed.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/uu/sed/src/sed.rs b/src/uu/sed/src/sed.rs index fa203ab9..7976f99d 100644 --- a/src/uu/sed/src/sed.rs +++ b/src/uu/sed/src/sed.rs @@ -4,12 +4,7 @@ // file that was distributed with this source code. use clap::{arg, Command}; -use std::{ - fs, - io::{self, BufRead, Write}, - process, -}; -use uucore::{error::UResult, format_usage, help_about, help_usage}; +use uucore::{error::UResult, format_usage}; const ABOUT: &str = "Stream editor for filtering and transforming text"; const USAGE: &str = "sed [-n] script [file...]"; From 59da6837929fdde4946d595764829e2d80e9ceb4 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 15:24:20 +0100 Subject: [PATCH 2/6] Fix "unused variable" warning --- src/uu/sed/src/sed.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uu/sed/src/sed.rs b/src/uu/sed/src/sed.rs index 7976f99d..8f73f23e 100644 --- a/src/uu/sed/src/sed.rs +++ b/src/uu/sed/src/sed.rs @@ -11,7 +11,8 @@ const USAGE: &str = "sed [-n] script [file...]"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let matches = uu_app().try_get_matches_from(args)?; + // TODO remove underscore prefix when var is used + let _matches = uu_app().try_get_matches_from(args)?; // TODO Ok(()) } From a4b7ae74ba1f15dff2a9f6bc67b538370966765f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 15:33:21 +0100 Subject: [PATCH 3/6] clippy: allow cognitive_complexity for uu_app fn --- src/uu/sed/src/sed.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/sed/src/sed.rs b/src/uu/sed/src/sed.rs index 8f73f23e..7ce66d00 100644 --- a/src/uu/sed/src/sed.rs +++ b/src/uu/sed/src/sed.rs @@ -17,6 +17,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } +#[allow(clippy::cognitive_complexity)] pub fn uu_app() -> Command { Command::new(uucore::util_name()) .about(ABOUT) From c0387ed7ebc9fdc5ed7c0385ca1d3690f7eb964f Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 16:00:59 +0100 Subject: [PATCH 4/6] tests: fix warnings in testing framework --- tests/common/util.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 9f1d6e15..23c559eb 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -5,7 +5,7 @@ //spell-checker: ignore (linux) rlimit prlimit coreutil ggroups uchild uncaptured scmd SHLVL canonicalized -#![allow(dead_code)] +#![allow(dead_code, unexpected_cfgs)] use pretty_assertions::assert_eq; #[cfg(any(target_os = "linux", target_os = "android"))] @@ -25,7 +25,7 @@ use std::os::unix::process::ExitStatusExt; #[cfg(windows)] use std::os::windows::fs::{symlink_dir, symlink_file}; #[cfg(windows)] -use std::path::MAIN_SEPARATOR; +use std::path::MAIN_SEPARATOR_STR; use std::path::{Path, PathBuf}; use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::rc::Rc; @@ -171,7 +171,7 @@ impl CmdResult { /// Assert `stdout` as bytes with a predicate function returning a `bool`. #[track_caller] - pub fn stdout_check<'a, F>(&'a self, predicate: F) -> &Self + pub fn stdout_check<'a, F>(&'a self, predicate: F) -> &'a Self where F: Fn(&'a [u8]) -> bool, { @@ -186,7 +186,7 @@ impl CmdResult { /// Assert `stdout` as `&str` with a predicate function returning a `bool`. #[track_caller] - pub fn stdout_str_check<'a, F>(&'a self, predicate: F) -> &Self + pub fn stdout_str_check<'a, F>(&'a self, predicate: F) -> &'a Self where F: Fn(&'a str) -> bool, { @@ -201,7 +201,7 @@ impl CmdResult { /// Assert `stderr` as bytes with a predicate function returning a `bool`. #[track_caller] - pub fn stderr_check<'a, F>(&'a self, predicate: F) -> &Self + pub fn stderr_check<'a, F>(&'a self, predicate: F) -> &'a Self where F: Fn(&'a [u8]) -> bool, { @@ -216,7 +216,7 @@ impl CmdResult { /// Assert `stderr` as `&str` with a predicate function returning a `bool`. #[track_caller] - pub fn stderr_str_check<'a, F>(&'a self, predicate: F) -> &Self + pub fn stderr_str_check<'a, F>(&'a self, predicate: F) -> &'a Self where F: Fn(&'a str) -> bool, { @@ -993,7 +993,7 @@ impl AtPath { pub fn relative_symlink_file(&self, original: &str, link: &str) { #[cfg(windows)] - let original = original.replace('/', &MAIN_SEPARATOR.to_string()); + let original = original.replace('/', MAIN_SEPARATOR_STR); log_info( "symlink", format!("{},{}", &original, &self.plus_as_string(link)), @@ -1015,7 +1015,7 @@ impl AtPath { pub fn relative_symlink_dir(&self, original: &str, link: &str) { #[cfg(windows)] - let original = original.replace('/', &MAIN_SEPARATOR.to_string()); + let original = original.replace('/', MAIN_SEPARATOR_STR); log_info( "symlink", format!("{},{}", &original, &self.plus_as_string(link)), @@ -1401,12 +1401,12 @@ impl UCommand { /// /// These __defaults__ are: /// * `bin_path`: Depending on the platform and os, the native shell (unix -> `/bin/sh` etc.). - /// This default also requires to set the first argument to `-c` on unix (`/C` on windows) if - /// this argument wasn't specified explicitly by the user. + /// This default also requires to set the first argument to `-c` on unix (`/C` on windows) if + /// this argument wasn't specified explicitly by the user. /// * `util_name`: `None`. If neither `bin_path` nor `util_name` were given the arguments are - /// run in a shell (See `bin_path` above). + /// run in a shell (See `bin_path` above). /// * `temp_dir`: If `current_dir` was not set, a new temporary directory will be created in - /// which this command will be run and `current_dir` will be set to this `temp_dir`. + /// which this command will be run and `current_dir` will be set to this `temp_dir`. /// * `current_dir`: The temporary directory given by `temp_dir`. /// * `timeout`: `30 seconds` /// * `stdin`: `Stdio::null()` From 4b36e2b55175e05aa6a330b2e390cb500de80b03 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 16:02:40 +0100 Subject: [PATCH 5/6] Fix warnings in test --- tests/by-util/test_sed.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/by-util/test_sed.rs b/tests/by-util/test_sed.rs index 05536e19..ec9855a1 100644 --- a/tests/by-util/test_sed.rs +++ b/tests/by-util/test_sed.rs @@ -2,10 +2,6 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (words) symdir somefakedir - -use pretty_assertions::assert_eq; -use regex::Regex; use crate::common::util::TestScenario; @@ -16,5 +12,5 @@ fn test_invalid_arg() { #[test] fn test_sed() { - let result = new_ucmd!().succeeds(); + new_ucmd!().succeeds(); } From c6605f94837ab9b83b294eebfb99b4c637a728eb Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 24 Feb 2025 16:07:29 +0100 Subject: [PATCH 6/6] Fix incorrect main.rs --- src/uu/sed/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/sed/src/main.rs b/src/uu/sed/src/main.rs index 9b196ed9..e8162660 100644 --- a/src/uu/sed/src/main.rs +++ b/src/uu/sed/src/main.rs @@ -1 +1 @@ -uucore::bin!(uu_free); +uucore::bin!(uu_sed);