Skip to content

Commit dccd39b

Browse files
Brooooooklynclaude
andauthored
style: fix clippy::uninlined_format_args warnings (#232)
Use inline format args in format strings for better readability and performance. Changed format!("{}", var) to format!("{var}"). Fixed 13 occurrences across: - crates/fspy/build.rs (7 fixes) - crates/fspy_shared_unix/src/payload.rs (1 fix) - crates/fspy_preload_unix/src/client/mod.rs (2 fixes) - crates/fspy/examples/cli.rs (1 fix) - crates/fspy_e2e/src/main.rs (2 fixes) All tests pass and clippy is clean with -D clippy::uninlined_format_args. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fd36c42 commit dccd39b

5 files changed

Lines changed: 13 additions & 15 deletions

File tree

crates/fspy/build.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ fn unpack_tar_gz(content: impl Read, path: &str) -> anyhow::Result<Vec<u8>> {
3131
return Ok(data);
3232
}
3333
}
34-
bail!("Path {} not found in tar gz", path)
34+
bail!("Path {path} not found in tar gz")
3535
}
3636

3737
fn download_and_unpack_tar_gz(url: &str, path: &str) -> anyhow::Result<Vec<u8>> {
38-
let resp = download(url).context(format!("Failed to get ok response from {}", url))?;
38+
let resp = download(url).context(format!("Failed to get ok response from {url}"))?;
3939
let data = unpack_tar_gz(resp, path)
40-
.context(format!("Failed to download or unpack {} out of {}", path, url))?;
40+
.context(format!("Failed to download or unpack {path} out of {url}"))?;
4141
Ok(data)
4242
}
4343

@@ -84,13 +84,13 @@ fn fetch_macos_binaries() -> anyhow::Result<()> {
8484
let downloads = MACOS_BINARY_DOWNLOADS
8585
.iter()
8686
.find(|(arch, _)| *arch == target_arch)
87-
.context(format!("Unsupported macOS arch: {}", target_arch))?
87+
.context(format!("Unsupported macOS arch: {target_arch}"))?
8888
.1;
8989
// let downloads = [(zsh_url.as_str(), "bin/zsh", zsh_hash)];
9090
for (url, path_in_targz, expected_hash) in downloads.iter().copied() {
9191
let filename = path_in_targz.split('/').next_back().unwrap();
9292
let download_path = out_dir.join(filename);
93-
let hash_path = out_dir.join(format!("{}.hash", filename));
93+
let hash_path = out_dir.join(format!("{filename}.hash"));
9494

9595
let file_exists = matches!(fs::read(&download_path), Ok(existing_file_data) if xxh3_128(&existing_file_data) == expected_hash);
9696
if !file_exists {
@@ -102,11 +102,10 @@ fn fetch_macos_binaries() -> anyhow::Result<()> {
102102
let actual_hash = xxh3_128(&data);
103103
assert_eq!(
104104
actual_hash, expected_hash,
105-
"expected_hash of {} in {} needs to be updated",
106-
path_in_targz, url
105+
"expected_hash of {path_in_targz} in {url} needs to be updated"
107106
);
108107
}
109-
fs::write(&hash_path, format!("{:x}", expected_hash))?;
108+
fs::write(&hash_path, format!("{expected_hash:x}"))?;
110109
}
111110
Ok(())
112111
// let zsh_path = ensure_downloaded(&zsh_url);

crates/fspy/examples/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ async fn main() -> io::Result<()> {
4848
csv_writer.flush().await?;
4949

5050
let output = tokio_child.wait().await?;
51-
eprintln!("\nfspy: {} paths accessed. {}", path_count, output);
51+
eprintln!("\nfspy: {path_count} paths accessed. {output}");
5252
Ok(())
5353
}

crates/fspy_e2e/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ async fn main() {
109109
for access in accesses.iter() {
110110
collector.add(access);
111111
}
112-
let snap_file = File::create(manifest_dir.join(format!("snaps/{}.txt", name))).unwrap();
112+
let snap_file = File::create(manifest_dir.join(format!("snaps/{name}.txt"))).unwrap();
113113
let mut snap_writer = BufWriter::new(snap_file);
114114
for (path, mode) in collector.iter() {
115-
writeln!(snap_writer, "{}: {:?}", path, mode).unwrap();
115+
writeln!(snap_writer, "{path}: {mode:?}").unwrap();
116116
}
117117
}
118118
}

crates/fspy_preload_unix/src/client/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ impl Client {
127127
*shm_buf = self.new_shm()?;
128128
let buf = shm_buf.advance(len).with_context(|| {
129129
format!(
130-
"The requested buf ({}) is greater than the shm chunk size ({})",
131-
len, SHM_CHUNK_SIZE
130+
"The requested buf ({len}) is greater than the shm chunk size ({SHM_CHUNK_SIZE})"
132131
)
133132
})?;
134133
f(buf)
@@ -304,6 +303,6 @@ fn init_client() {
304303
CLIENT.set(Client::from_env()).unwrap();
305304
let ret = unsafe { pthread_atfork(None, None, Some(reset_shm_atfork)) };
306305
if ret != 0 {
307-
panic!("pthread_atfork failed: {}", ret);
306+
panic!("pthread_atfork failed: {ret}");
308307
}
309308
}

crates/fspy_shared_unix/src/payload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn encode_payload(payload: Payload) -> EncodedPayload {
4848
/// - The bincode deserialization fails
4949
pub fn decode_payload_from_env() -> anyhow::Result<EncodedPayload> {
5050
let Some(encoded_string) = std::env::var_os(PAYLOAD_ENV_NAME) else {
51-
anyhow::bail!("Environment variable '{}' not found", PAYLOAD_ENV_NAME);
51+
anyhow::bail!("Environment variable '{PAYLOAD_ENV_NAME}' not found");
5252
};
5353
decode_payload(encoded_string.into_vec().into())
5454
}

0 commit comments

Comments
 (0)