From d0494504a1df4e13ecd4eeae0495066c81060cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Tue, 15 Jul 2025 15:44:34 -0300 Subject: [PATCH] Fix clippy warnings (#833) --- src/check.rs | 3 +-- src/commands/decompress.rs | 2 +- src/error.rs | 4 ++-- src/extension.rs | 2 +- src/utils/formatting.rs | 2 +- src/utils/fs.rs | 2 +- src/utils/question.rs | 8 ++++---- tests/integration.rs | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/check.rs b/src/check.rs index bcad3cf..c091b8a 100644 --- a/src/check.rs +++ b/src/check.rs @@ -56,8 +56,7 @@ pub fn check_mime_type( .ends_with(detected_format.compression_formats) { warning(format!( - "The file extension: `{}` differ from the detected extension: `{}`", - outer_ext, detected_format + "The file extension: `{outer_ext}` differ from the detected extension: `{detected_format}`" )); if !user_wants_to_continue(path, question_policy, QuestionAction::Decompression)? { diff --git a/src/commands/decompress.rs b/src/commands/decompress.rs index 6c254ad..780c392 100644 --- a/src/commands/decompress.rs +++ b/src/commands/decompress.rs @@ -295,7 +295,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> { "Successfully decompressed archive in {}", nice_directory_display(options.output_dir) )); - info_accessible(format!("Files unpacked: {}", files_unpacked)); + info_accessible(format!("Files unpacked: {files_unpacked}")); if !input_is_stdin && options.remove { fs::remove_file(options.input_file_path)?; diff --git a/src/error.rs b/src/error.rs index b3c33df..167bc7b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -139,8 +139,8 @@ impl FinalError { /// hint: Supported aliases are: tgz, tbz, tlz4, txz, tzlma, tsz, tzst /// ``` pub fn hint_all_supported_formats(self) -> Self { - self.hint(format!("Supported extensions are: {}", PRETTY_SUPPORTED_EXTENSIONS)) - .hint(format!("Supported aliases are: {}", PRETTY_SUPPORTED_ALIASES)) + self.hint(format!("Supported extensions are: {PRETTY_SUPPORTED_EXTENSIONS}")) + .hint(format!("Supported aliases are: {PRETTY_SUPPORTED_ALIASES}")) } } diff --git a/src/extension.rs b/src/extension.rs index 48be0cb..e886634 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -173,7 +173,7 @@ pub fn parse_format_flag(input: &OsStr) -> crate::Result> { .map(|extension| { to_extension(extension.as_bytes()).ok_or_else(|| Error::InvalidFormatFlag { text: input.to_owned(), - reason: format!("Unsupported extension '{}'", extension), + reason: format!("Unsupported extension '{extension}'"), }) }) .collect::>()?; diff --git a/src/utils/formatting.rs b/src/utils/formatting.rs index 3b82a09..8c045ca 100644 --- a/src/utils/formatting.rs +++ b/src/utils/formatting.rs @@ -109,7 +109,7 @@ impl std::fmt::Display for Bytes { debug_assert!(num >= 0.0); if num < 1_f64 { - return write!(f, "{:>6.2} B", num); + return write!(f, "{num:>6.2} B"); } let delimiter = 1000_f64; diff --git a/src/utils/fs.rs b/src/utils/fs.rs index f65f152..21c2457 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -82,7 +82,7 @@ pub fn rename_or_increment_filename(path: &Path) -> PathBuf { let number = number_str.parse::().unwrap_or(0); format!("{}_{}", base, number + 1) } - _ => format!("{}_1", filename), + _ => format!("{filename}_1"), }; let mut new_path = parent.join(new_filename); diff --git a/src/utils/question.rs b/src/utils/question.rs index 4b4c97e..fbed15c 100644 --- a/src/utils/question.rs +++ b/src/utils/question.rs @@ -187,7 +187,7 @@ impl<'a, T: Default> ChoicePrompt<'a, T> { #[cfg(not(feature = "allow_piped_choice"))] if !stdin().is_terminal() { - eprintln!("{}", message); + eprintln!("{message}"); eprintln!("Pass --yes to proceed"); return Ok(T::default()); } @@ -222,10 +222,10 @@ impl<'a, T: Default> ChoicePrompt<'a, T> { .collect::>() .join("/"); - format!("[{}]", choises) + format!("[{choises}]") }; - eprintln!("{} {}", message, choice_prompt); + eprintln!("{message} {choice_prompt}"); let mut answer = String::new(); let bytes_read = stdin_lock.read_line(&mut answer)?; @@ -284,7 +284,7 @@ impl<'a> Confirmation<'a> { #[cfg(not(feature = "allow_piped_choice"))] if !stdin().is_terminal() { - eprintln!("{}", message); + eprintln!("{message}"); eprintln!("Pass --yes to proceed"); return Ok(false); } diff --git a/tests/integration.rs b/tests/integration.rs index 9f870db..1883b0e 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -175,7 +175,7 @@ fn single_file_stdin( fs::create_dir(before).unwrap(); let before_file = &before.join("file"); let format = merge_extensions(&ext, &exts); - let archive = &dir.join(format!("file.{}", format)); + let archive = &dir.join(format!("file.{format}")); let after = &dir.join("after"); write_random_content( &mut fs::File::create(before_file).unwrap(),