From 0e9d7607e4aa0b9673af42cd2de6f6769c87d627 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Sat, 1 Nov 2025 11:56:14 +0100 Subject: [PATCH] hooks: Enable typos, fix reported errors --- .codespellrc | 4 ++-- .typos.toml | 16 ++++++++++++++++ build.rs | 2 +- crates/radicle-protocol/src/service/limiter.rs | 6 +++--- crates/radicle-ssh/src/encoding.rs | 2 +- flake.nix | 7 +++++++ 6 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 .typos.toml diff --git a/.codespellrc b/.codespellrc index 95991276..5940b8cd 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,4 @@ [codespell] -skip = .git*,*.lock,.codespellrc +skip = .git*,*.lock,.codespellrc,target,.jj check-hidden = true -ignore-words-list = ser,noes +ignore-words-list = set,noes diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 00000000..7ee1b6d4 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,16 @@ +[default] +extend-ignore-re = [ + "[0-9a-f]{7}\\.\\.\\.?[0-9a-f]{7}", # Git range between two short commit IDs + "[0-9a-f]{7}\\[\\.\\.\\]", # Shortened commit IDs as written in tests + "did:key:z6Mk[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{44}", + "rad://z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{28}", + "rad:z[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{28}", + "z6Mk[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{44}", +] + +[default.extend-identifiers] +"typ" = "typ" # We may write "typ" instead of "type". The latter is a Rust keyword. + +[type.codespell] +check-file = false +extend-glob = [".codespellrc"] diff --git a/build.rs b/build.rs index ebeefed0..4cdd62b4 100644 --- a/build.rs +++ b/build.rs @@ -31,7 +31,7 @@ fn main() -> Result<(), Box> { // x.y.z, with efe10f95be being a unique prefix of the OID of // `HEAD`, and the working directory was dirty. // If this is a build pointing to a commit that has release tag, this - // will just return the tag name itelf, e.g. `releases/x.y.z`. + // will just return the tag name itself, e.g. `releases/x.y.z`. // If all fails, we just use `hash`, which, in the worst case is // still "unknown" (see above) but in most cases will just be // the short OID of `HEAD`. diff --git a/crates/radicle-protocol/src/service/limiter.rs b/crates/radicle-protocol/src/service/limiter.rs index 704f0f81..a7021e0a 100644 --- a/crates/radicle-protocol/src/service/limiter.rs +++ b/crates/radicle-protocol/src/service/limiter.rs @@ -156,7 +156,7 @@ mod test { } #[test] - fn test_limitter_refill() { + fn test_limiter_refill() { let mut r = RateLimiter::default(); let t = (3, 0.2); // Three tokens burst. One token every 5 seconds. let a = HostName::Dns(String::from("seed.radicle.example.com")); @@ -188,7 +188,7 @@ mod test { #[test] #[rustfmt::skip] - fn test_limitter_multi() { + fn test_limiter_multi() { let t = (1, 1.0); // One token per second. One token burst. let n = arbitrary::gen::(1); let n = Some(&n); @@ -208,7 +208,7 @@ mod test { #[test] #[rustfmt::skip] - fn test_limitter_different_rates() { + fn test_limiter_different_rates() { let t1 = (1, 1.0); // One token per second. One token burst. let t2 = (2, 2.0); // Two tokens per second. Two token burst. let n = arbitrary::gen::(1); diff --git a/crates/radicle-ssh/src/encoding.rs b/crates/radicle-ssh/src/encoding.rs index 2cce8ef3..db3df0ac 100644 --- a/crates/radicle-ssh/src/encoding.rs +++ b/crates/radicle-ssh/src/encoding.rs @@ -56,7 +56,7 @@ pub trait Encoding { /// May panic if the argument is greater than [`u32::MAX`]. /// This is a convenience method, to spare callers casting or converting /// [`usize`] to [`u32`]. If callers end up in a situation where they - /// need to push a 32-bit unisgned integer, but the value they would + /// need to push a 32-bit unsigned integer, but the value they would /// like to push does not fit 32 bits, then the implementation will not /// comply with the SSH format anyway. fn extend_usize(&mut self, u: usize) { diff --git a/flake.nix b/flake.nix index 91ac878e..f2fc7061 100644 --- a/flake.nix +++ b/flake.nix @@ -235,6 +235,13 @@ hooks = { alejandra.enable = true; + typos = { + enable = true; + settings = { + verbose = true; + write = true; + }; + }; codespell = { enable = true; entry = "${lib.getExe pkgs.codespell} -w";