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 c416e90cb26e89fe3536276c64f53028b72a50b1 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 27 Sep 2024 11:44:21 -0500 Subject: [PATCH 5/5] style: Inline fmt args --- crates/env_filter/src/parser.rs | 8 ++++---- src/fmt/mod.rs | 8 ++++---- src/fmt/writer/buffer.rs | 4 ++-- tests/init-twice-retains-filter.rs | 2 +- tests/log-in-log.rs | 2 +- tests/log_tls_dtors.rs | 2 +- tests/regexp_filter.rs | 9 +++------ 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/crates/env_filter/src/parser.rs b/crates/env_filter/src/parser.rs index 59596dd..097058d 100644 --- a/crates/env_filter/src/parser.rs +++ b/crates/env_filter/src/parser.rs @@ -62,7 +62,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult { let mods = parts.next(); let filter = parts.next(); if parts.next().is_some() { - result.add_error(format!("invalid logging spec '{}' (too many '/'s)", spec)); + result.add_error(format!("invalid logging spec '{spec}' (too many '/'s)")); return result; } if let Some(m) = mods { @@ -86,12 +86,12 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult { if let Ok(num) = part1.parse() { (num, Some(part0)) } else { - result.add_error(format!("invalid logging spec '{}'", part1)); + result.add_error(format!("invalid logging spec '{part1}'")); continue; } } _ => { - result.add_error(format!("invalid logging spec '{}'", s)); + result.add_error(format!("invalid logging spec '{s}'")); continue; } }; @@ -106,7 +106,7 @@ pub(crate) fn parse_spec(spec: &str) -> ParseResult { if let Some(filter) = filter { match FilterOp::new(filter) { Ok(filter_op) => result.set_filter(filter_op), - Err(err) => result.add_error(format!("invalid regex filter - {}", err)), + Err(err) => result.add_error(format!("invalid regex filter - {err}")), } } diff --git a/src/fmt/mod.rs b/src/fmt/mod.rs index 0854e51..c495eb5 100644 --- a/src/fmt/mod.rs +++ b/src/fmt/mod.rs @@ -357,9 +357,9 @@ impl<'a> DefaultFormat<'a> { self.written_header_value = true; let open_brace = self.subtle_style("["); - write!(self.buf, "{}{}", open_brace, value) + write!(self.buf, "{open_brace}{value}") } else { - write!(self.buf, " {}", value) + write!(self.buf, " {value}") } } @@ -383,7 +383,7 @@ impl<'a> DefaultFormat<'a> { } }; - self.write_header_value(format_args!("{:<5}", level)) + self.write_header_value(format_args!("{level:<5}")) } fn write_timestamp(&mut self) -> io::Result<()> { @@ -435,7 +435,7 @@ impl<'a> DefaultFormat<'a> { fn finish_header(&mut self) -> io::Result<()> { if self.written_header_value { let close_brace = self.subtle_style("]"); - write!(self.buf, "{} ", close_brace) + write!(self.buf, "{close_brace} ") } else { Ok(()) } diff --git a/src/fmt/writer/buffer.rs b/src/fmt/writer/buffer.rs index 0a8ac36..c73b958 100644 --- a/src/fmt/writer/buffer.rs +++ b/src/fmt/writer/buffer.rs @@ -71,7 +71,7 @@ impl BufferWriter { #[cfg(feature = "color")] let buf = &buf; let buf = String::from_utf8_lossy(buf); - print!("{}", buf); + print!("{buf}"); } WritableTarget::WriteStderr => { let stream = io::stderr(); @@ -87,7 +87,7 @@ impl BufferWriter { #[cfg(feature = "color")] let buf = &buf; let buf = String::from_utf8_lossy(buf); - eprint!("{}", buf); + eprint!("{buf}"); } WritableTarget::Pipe(pipe) => { #[cfg(feature = "color")] diff --git a/tests/init-twice-retains-filter.rs b/tests/init-twice-retains-filter.rs index cc9fded..d66367a 100644 --- a/tests/init-twice-retains-filter.rs +++ b/tests/init-twice-retains-filter.rs @@ -27,7 +27,7 @@ fn main() { .env("YOU_ARE_TESTING_NOW", "1") .env("RUST_LOG", "debug") .output() - .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + .unwrap_or_else(|e| panic!("Unable to start child process: {e}")); if out.status.success() { return; } diff --git a/tests/log-in-log.rs b/tests/log-in-log.rs index 1ed9be9..93348cd 100644 --- a/tests/log-in-log.rs +++ b/tests/log-in-log.rs @@ -28,7 +28,7 @@ fn main() { .env("YOU_ARE_TESTING_NOW", "1") .env("RUST_LOG", "debug") .output() - .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + .unwrap_or_else(|e| panic!("Unable to start child process: {e}")); if out.status.success() { return; } diff --git a/tests/log_tls_dtors.rs b/tests/log_tls_dtors.rs index 8ebae39..6876c07 100644 --- a/tests/log_tls_dtors.rs +++ b/tests/log_tls_dtors.rs @@ -56,7 +56,7 @@ fn main() { .env("YOU_ARE_TESTING_NOW", "1") .env("RUST_LOG", "debug") .output() - .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + .unwrap_or_else(|e| panic!("Unable to start child process: {e}")); if !out.status.success() { println!("test failed: {}", out.status); println!("--- stdout\n{}", str::from_utf8(&out.stdout).unwrap()); diff --git a/tests/regexp_filter.rs b/tests/regexp_filter.rs index af2864d..25ceca0 100644 --- a/tests/regexp_filter.rs +++ b/tests/regexp_filter.rs @@ -26,7 +26,7 @@ fn run_child(rust_log: String) -> bool { .env("LOG_REGEXP_TEST", "1") .env("RUST_LOG", rust_log) .output() - .unwrap_or_else(|e| panic!("Unable to start child process: {}", e)); + .unwrap_or_else(|e| panic!("Unable to start child process: {e}")); str::from_utf8(out.stderr.as_ref()) .unwrap() .contains("XYZ Message") @@ -34,16 +34,13 @@ fn run_child(rust_log: String) -> bool { fn assert_message_printed(rust_log: &str) { if !run_child(rust_log.to_owned()) { - panic!("RUST_LOG={} should allow the test log message", rust_log) + panic!("RUST_LOG={rust_log} should allow the test log message") } } fn assert_message_not_printed(rust_log: &str) { if run_child(rust_log.to_owned()) { - panic!( - "RUST_LOG={} should not allow the test log message", - rust_log - ) + panic!("RUST_LOG={rust_log} should not allow the test log message") } }