Skip to content

Commit 881b5d3

Browse files
authored
chore: fix all clippy issues
(#147) Resolve all errors from `cargo clippy --workspace --all-targets --all-features -- --deny warnings` across every crate.
1 parent e519e97 commit 881b5d3

137 files changed

Lines changed: 2552 additions & 1187 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ rustflags = ["--cfg", "tokio_unstable"] # also update .github/workflows/ci.yml
33

44
[unstable]
55
bindeps = true
6+
7+
# Linker wrappers for cross-compiling bindep targets (fspy_test_bin) via cargo-zigbuild.
8+
# On native Linux the system linker can handle musl targets; these are needed on non-Linux hosts.
9+
[target.x86_64-unknown-linux-musl]
10+
rustflags = ["-C", "linker=.cargo/zigcc-x86_64-unknown-linux-musl"]
11+
12+
[target.aarch64-unknown-linux-musl]
13+
rustflags = ["-C", "linker=.cargo/zigcc-aarch64-unknown-linux-musl"]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec cargo-zigbuild zig cc -- -fno-sanitize=all -target aarch64-linux-musl "$@"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec cargo-zigbuild zig cc -- -fno-sanitize=all -target x86_64-linux-musl "$@"

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
with:
5151
save-cache: ${{ github.ref_name == 'main' }}
5252
cache-key: test
53+
components: clippy
5354

5455
- run: rustup target add ${{ matrix.target }}
5556

@@ -63,6 +64,8 @@ jobs:
6364
env:
6465
RUSTFLAGS: '-D warnings --cfg tokio_unstable' # also update .cargo/config.toml
6566

67+
- run: cargo clippy --all-targets --all-features -- -D warnings
68+
6669
# Set up node and pnpm for running tests
6770
# For x86_64-apple-darwin, use x64 node for fspy tests that verify Node.js fs accesses
6871
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
@@ -84,8 +87,8 @@ jobs:
8487
- run: cargo-zigbuild test --target x86_64-unknown-linux-gnu.2.17
8588
if: ${{ matrix.os == 'ubuntu-latest' }}
8689

87-
lint:
88-
name: Lint
90+
fmt:
91+
name: Format and Check Deps
8992
runs-on: ubuntu-latest
9093
steps:
9194
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -96,14 +99,13 @@ jobs:
9699
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
97100
with:
98101
save-cache: ${{ github.ref_name == 'main' }}
99-
cache-key: lint
102+
cache-key: fmt
100103
tools: dprint,cargo-shear
101104
components: clippy rust-docs rustfmt
102105

103106
- run: dprint check
104107
- run: cargo shear
105108
- run: cargo fmt --check
106-
# - run: cargo clippy --all-targets --all-features -- -D warnings
107109
- run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
108110

109111
- uses: crate-ci/typos@85f62a8a84f939ae994ab3763f01a0296d61a7ee # v1.36.2
@@ -119,7 +121,7 @@ jobs:
119121
runs-on: ubuntu-latest
120122
needs:
121123
- test
122-
- lint
124+
- fmt
123125
steps:
124126
- run: exit 1
125127
# Thank you, next https://github.com/vercel/next.js/blob/canary/.github/workflows/build_and_test.yml#L379

.rustfmt.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ reorder_impl_items = true
1616
group_imports = "StdExternalCrate"
1717
# Group "use" statements by crate
1818
imports_granularity = "Crate"
19+
20+
# Skip generated files
21+
ignore = [
22+
"crates/fspy_detours_sys/src/generated_bindings.rs",
23+
]

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ just fmt # Format code (cargo fmt, cargo shear, dprint)
1313
just check # Check compilation with all features
1414
just test # Run all tests
1515
just lint # Clippy linting
16+
just lint-linux # Cross-clippy for Linux (requires cargo-zigbuild)
17+
just lint-windows # Cross-clippy for Windows (requires cargo-xwin)
1618
just doc # Documentation generation
1719
```
1820

@@ -88,6 +90,16 @@ Tasks are defined in `vite-task.json`:
8890
- With `-r/--recursive`: runs task across all packages in dependency order
8991
- With `-t/--transitive`: runs task in current package and its dependencies
9092

93+
## Cross-Platform Linting
94+
95+
After major changes (especially to `fspy*` or platform-specific crates), run cross-platform clippy before pushing:
96+
97+
```bash
98+
just lint # native (host platform)
99+
just lint-linux # Linux via cargo-zigbuild
100+
just lint-windows # Windows via cargo-xwin
101+
```
102+
91103
## Code Constraints
92104

93105
These patterns are enforced by `.clippy.toml`:

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ unimplemented = "warn"
2727
print_stdout = "warn"
2828
print_stderr = "warn"
2929
allow_attributes = "warn"
30+
allow_attributes_without_reason = "warn"
31+
undocumented_unsafe_blocks = "warn"
3032
pedantic = { level = "warn", priority = -1 }
3133
nursery = { level = "warn", priority = -1 }
3234
cargo = { level = "warn", priority = -1 }
3335
cargo_common_metadata = "allow"
36+
multiple_crate_versions = "allow"
3437

3538
[workspace.dependencies]
3639
allocator-api2 = { version = "0.2.21", default-features = false, features = ["alloc", "std"] }

crates/fspy/build.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#![allow(
2+
clippy::disallowed_types,
3+
clippy::disallowed_methods,
4+
clippy::disallowed_macros,
5+
reason = "non-vite crate"
6+
)]
7+
18
use std::{
29
env::{self, current_dir},
310
fs,
@@ -21,7 +28,7 @@ fn download(url: &str) -> anyhow::Result<impl Read + use<>> {
2128
let output = curl.wait_with_output()?;
2229
if !output.status.success() {
2330
bail!("curl exited with status {} trying to download {}", output.status, url);
24-
};
31+
}
2532
Ok(Cursor::new(output.stdout))
2633
}
2734

@@ -50,19 +57,22 @@ fn download_and_unpack_tar_gz(url: &str, path: &str) -> anyhow::Result<Vec<u8>>
5057
Ok(data)
5158
}
5259

53-
const MACOS_BINARY_DOWNLOADS: &[(&str, &[(&str, &str, u128)])] = &[
60+
/// (url, `path_in_targz`, `expected_hash`)
61+
type BinaryDownload = (&'static str, &'static str, u128);
62+
63+
const MACOS_BINARY_DOWNLOADS: &[(&str, &[BinaryDownload])] = &[
5464
(
5565
"aarch64",
5666
&[
5767
(
5868
"https://github.com/branchseer/oils-for-unix-build/releases/download/oils-for-unix-0.37.0/oils-for-unix-0.37.0-darwin-arm64.tar.gz",
5969
"oils-for-unix",
60-
282073174065923237490435663309538399576,
70+
282_073_174_065_923_237_490_435_663_309_538_399_576,
6171
),
6272
(
6373
"https://github.com/uutils/coreutils/releases/download/0.4.0/coreutils-0.4.0-aarch64-apple-darwin.tar.gz",
6474
"coreutils-0.4.0-aarch64-apple-darwin/coreutils",
65-
35998406686137668997937014088186935383,
75+
35_998_406_686_137_668_997_937_014_088_186_935_383,
6676
),
6777
],
6878
),
@@ -72,12 +82,12 @@ const MACOS_BINARY_DOWNLOADS: &[(&str, &[(&str, &str, u128)])] = &[
7282
(
7383
"https://github.com/branchseer/oils-for-unix-build/releases/download/oils-for-unix-0.37.0/oils-for-unix-0.37.0-darwin-x86_64.tar.gz",
7484
"oils-for-unix",
75-
142673558272427867831039361796426010330,
85+
142_673_558_272_427_867_831_039_361_796_426_010_330,
7686
),
7787
(
7888
"https://github.com/uutils/coreutils/releases/download/0.4.0/coreutils-0.4.0-x86_64-apple-darwin.tar.gz",
7989
"coreutils-0.4.0-x86_64-apple-darwin/coreutils",
80-
120898281113671104995723556995187526689,
90+
120_898_281_113_671_104_995_723_556_995_187_526_689,
8191
),
8292
],
8393
),

crates/fspy/examples/cli.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#![allow(
2+
clippy::disallowed_types,
3+
clippy::disallowed_methods,
4+
clippy::disallowed_macros,
5+
reason = "non-vite crate"
6+
)]
7+
18
use std::{env::args_os, ffi::OsStr, path::PathBuf, pin::Pin};
29

310
use tokio::{
@@ -29,15 +36,22 @@ async fn main() -> anyhow::Result<()> {
2936

3037
for acc in termination.path_accesses.iter() {
3138
path_count += 1;
39+
let mode_str = format!("{:?}", acc.mode);
3240
csv_writer
3341
.write_record(&[
3442
acc.path.to_cow_os_str().to_string_lossy().as_ref().as_bytes(),
35-
format!("{:?}", acc.mode).as_bytes(),
43+
mode_str.as_bytes(),
3644
])
3745
.await?;
3846
}
3947
csv_writer.flush().await?;
4048

41-
eprintln!("\nfspy: {path_count} paths accessed. status: {}", termination.status);
49+
#[expect(
50+
clippy::print_stderr,
51+
reason = "CLI example: stderr output is intentional for user feedback"
52+
)]
53+
{
54+
eprintln!("\nfspy: {path_count} paths accessed. status: {}", termination.status);
55+
}
4256
Ok(())
4357
}

0 commit comments

Comments
 (0)