From 553258af51034bc84dc9f951201e7b8f2285b57e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 25 Jul 2024 15:35:58 -0700 Subject: [PATCH 1/5] Have clippy warn about uninlined format arguments This makes clippy warn about `format!("{}", var)`, with a machine-applicable fix converting to `format!("{var}")`. --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 90d89f6..97c7ed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ string_lit_as_bytes = "warn" string_to_string = "warn" todo = "warn" trait_duplication_in_bounds = "warn" +uninlined_format_args = "warn" verbose_file_reads = "warn" wildcard_imports = "warn" zero_sized_map_values = "warn" From 7a28f01acfe8eb95f4e54127e1b66aa31cf2aeed Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 23 Aug 2024 19:02:02 -0500 Subject: [PATCH 2/5] docs(contrib): Fix tpo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87d9134..b0318b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp PRs should tell a cohesive story, with test and refactor commits that keep the fix or feature commits simple and clear. -Specifically, we would encouage +Specifically, we would encourage - File renames be isolated into their own commit - Add tests in a commit before their feature or fix, showing the current behavior. The diff for the feature/fix commit will then show how the behavior changed, From 37cf1085bc6aa53e18a37f0aa97be51afa6e7f14 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 01:02:47 +0000 Subject: [PATCH 3/5] chore(deps): Update EmbarkStudios/cargo-deny-action action to v2 --- .github/workflows/audit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 07c70ee..a94be15 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -47,7 +47,7 @@ jobs: - bans licenses sources steps: - uses: actions/checkout@v4 - - uses: EmbarkStudios/cargo-deny-action@v1 + - uses: EmbarkStudios/cargo-deny-action@v2 with: command: check ${{ matrix.checks }} rust-version: stable From 6e193aa09aed80118df4e1317b8eed057bad6f0b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 26 Sep 2024 20:59:12 -0500 Subject: [PATCH 4/5] chore: Ensure pre-commit gets non-system Python This is needed with the ubuntu-24.04 images so that `setup-python` will install a version of Python that the pre-commit action can install into. See pre-commit/action#210 for more of an analysis of this. --- .github/workflows/pre-commit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1b000ab..7b55a3d 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,4 +24,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + with: + python-version: '3.x' - uses: pre-commit/action@v3.0.1 From ad5602f3e25c8c376f87694c812fbc929fe98daa Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 27 Sep 2024 11:44:28 -0500 Subject: [PATCH 5/5] style: Inline fmt args --- examples/example_fixture.rs | 6 +++--- src/bin/bin_fixture.rs | 6 +++--- src/error.rs | 4 ++-- src/format/mod.rs | 10 +++++----- src/run.rs | 8 ++------ tests/testsuite/build.rs | 8 ++++---- tests/testsuite/run.rs | 2 +- 7 files changed, 20 insertions(+), 24 deletions(-) diff --git a/examples/example_fixture.rs b/examples/example_fixture.rs index f47540f..62440fa 100644 --- a/examples/example_fixture.rs +++ b/examples/example_fixture.rs @@ -6,10 +6,10 @@ use std::process; fn run() -> Result<(), Box> { if let Ok(text) = env::var("stdout") { - println!("{}", text); + println!("{text}"); } if let Ok(text) = env::var("stderr") { - eprintln!("{}", text); + eprintln!("{text}"); } let code = env::var("exit") @@ -25,7 +25,7 @@ fn main() { let code = match run() { Ok(_) => 0, Err(ref e) => { - write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail"); 1 } }; diff --git a/src/bin/bin_fixture.rs b/src/bin/bin_fixture.rs index f47540f..62440fa 100644 --- a/src/bin/bin_fixture.rs +++ b/src/bin/bin_fixture.rs @@ -6,10 +6,10 @@ use std::process; fn run() -> Result<(), Box> { if let Ok(text) = env::var("stdout") { - println!("{}", text); + println!("{text}"); } if let Ok(text) = env::var("stderr") { - eprintln!("{}", text); + eprintln!("{text}"); } let code = env::var("exit") @@ -25,7 +25,7 @@ fn main() { let code = match run() { Ok(_) => 0, Err(ref e) => { - write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail"); 1 } }; diff --git a/src/error.rs b/src/error.rs index 4f19c40..50311eb 100644 --- a/src/error.rs +++ b/src/error.rs @@ -81,10 +81,10 @@ impl fmt::Display for CargoError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "Cargo command failed: {}", self.kind)?; if let Some(ref context) = self.context { - writeln!(f, "{}", context)?; + writeln!(f, "{context}")?; } if let Some(ref cause) = self.cause { - writeln!(f, "Cause: {}", cause)?; + writeln!(f, "Cause: {cause}")?; } Ok(()) } diff --git a/src/format/mod.rs b/src/format/mod.rs index c121b38..2ec94b0 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -247,11 +247,11 @@ pub(crate) fn log_message(msg: &Message<'_>) { .map(|s| s.as_ref()) .unwrap_or_else(|| comp.message.message.as_ref()); match comp.message.level { - diagnostic::DiagnosticLevel::Ice => eprintln!("{}", content), - diagnostic::DiagnosticLevel::Error => eprintln!("{}", content), - diagnostic::DiagnosticLevel::Warning => eprintln!("{}", content), - diagnostic::DiagnosticLevel::Note => eprintln!("{}", content), - diagnostic::DiagnosticLevel::Help => eprintln!("{}", content), + diagnostic::DiagnosticLevel::Ice => eprintln!("{content}"), + diagnostic::DiagnosticLevel::Error => eprintln!("{content}"), + diagnostic::DiagnosticLevel::Warning => eprintln!("{content}"), + diagnostic::DiagnosticLevel::Note => eprintln!("{content}"), + diagnostic::DiagnosticLevel::Help => eprintln!("{content}"), #[cfg(not(feature = "strict_unstable"))] _ => eprintln!("Unknown message: {:#?}", msg), } diff --git a/src/run.rs b/src/run.rs index 9e40d30..bf23ae4 100644 --- a/src/run.rs +++ b/src/run.rs @@ -181,12 +181,8 @@ fn extract_binary_path( if bins.is_empty() { return Err(CargoError::new(ErrorKind::CommandFailed).set_context("No binaries in crate")); } else if bins.len() != 1 { - return Err( - CargoError::new(ErrorKind::CommandFailed).set_context(std::format!( - "Ambiguous which binary is intended: {:?}", - bins - )), - ); + return Err(CargoError::new(ErrorKind::CommandFailed) + .set_context(std::format!("Ambiguous which binary is intended: {bins:?}"))); } Ok(bins.into_iter().next().expect("already validated")) } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 6c37541..edefc74 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -2,7 +2,7 @@ fn test_fixture(name: &str) { let temp = tempfile::TempDir::new().unwrap(); let msgs = escargot::CargoBuild::new() - .manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name)) + .manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml")) .current_release() .current_target() .target_dir(temp.path()) @@ -12,8 +12,8 @@ fn test_fixture(name: &str) { let raw_msg = msg.unwrap(); let msg = raw_msg.decode(); match msg { - Ok(msg) => println!("{:#?}", msg), - Err(err) => panic!("{}\nmsg=`{:#?}`", err, raw_msg), + Ok(msg) => println!("{msg:#?}"), + Err(err) => panic!("{err}\nmsg=`{raw_msg:#?}`"), } } } @@ -62,7 +62,7 @@ fn test_error() { for msg in &msgs[0..error_idx] { let msg = msg.as_ref().unwrap(); let msg = msg.decode().unwrap(); - println!("{:#?}", msg); + println!("{msg:#?}"); } assert!(msgs[error_idx].is_err()); println!("```{}```", msgs[error_idx].as_ref().err().unwrap()); diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index f94f207..f42975d 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -2,7 +2,7 @@ fn test_fixture(name: &str) { let temp = tempfile::TempDir::new().unwrap(); let cmd = escargot::CargoBuild::new() - .manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name)) + .manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml")) .current_release() .current_target() .target_dir(temp.path())