hooks: Enable typos, fix reported errors

This commit is contained in:
Lorenz Leutgeb 2025-11-01 11:56:14 +01:00 committed by Fintan Halpenny
parent 5fa68ed814
commit 0e9d7607e4
6 changed files with 30 additions and 7 deletions

View File

@ -1,4 +1,4 @@
[codespell] [codespell]
skip = .git*,*.lock,.codespellrc skip = .git*,*.lock,.codespellrc,target,.jj
check-hidden = true check-hidden = true
ignore-words-list = ser,noes ignore-words-list = set,noes

16
.typos.toml Normal file
View File

@ -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"]

View File

@ -31,7 +31,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// x.y.z, with efe10f95be being a unique prefix of the OID of // x.y.z, with efe10f95be being a unique prefix of the OID of
// `HEAD`, and the working directory was dirty. // `HEAD`, and the working directory was dirty.
// If this is a build pointing to a commit that has release tag, this // 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 // If all fails, we just use `hash`, which, in the worst case is
// still "unknown" (see above) but in most cases will just be // still "unknown" (see above) but in most cases will just be
// the short OID of `HEAD`. // the short OID of `HEAD`.

View File

@ -156,7 +156,7 @@ mod test {
} }
#[test] #[test]
fn test_limitter_refill() { fn test_limiter_refill() {
let mut r = RateLimiter::default(); let mut r = RateLimiter::default();
let t = (3, 0.2); // Three tokens burst. One token every 5 seconds. let t = (3, 0.2); // Three tokens burst. One token every 5 seconds.
let a = HostName::Dns(String::from("seed.radicle.example.com")); let a = HostName::Dns(String::from("seed.radicle.example.com"));
@ -188,7 +188,7 @@ mod test {
#[test] #[test]
#[rustfmt::skip] #[rustfmt::skip]
fn test_limitter_multi() { fn test_limiter_multi() {
let t = (1, 1.0); // One token per second. One token burst. let t = (1, 1.0); // One token per second. One token burst.
let n = arbitrary::gen::<NodeId>(1); let n = arbitrary::gen::<NodeId>(1);
let n = Some(&n); let n = Some(&n);
@ -208,7 +208,7 @@ mod test {
#[test] #[test]
#[rustfmt::skip] #[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 t1 = (1, 1.0); // One token per second. One token burst.
let t2 = (2, 2.0); // Two tokens per second. Two token burst. let t2 = (2, 2.0); // Two tokens per second. Two token burst.
let n = arbitrary::gen::<NodeId>(1); let n = arbitrary::gen::<NodeId>(1);

View File

@ -56,7 +56,7 @@ pub trait Encoding {
/// May panic if the argument is greater than [`u32::MAX`]. /// May panic if the argument is greater than [`u32::MAX`].
/// This is a convenience method, to spare callers casting or converting /// This is a convenience method, to spare callers casting or converting
/// [`usize`] to [`u32`]. If callers end up in a situation where they /// [`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 /// like to push does not fit 32 bits, then the implementation will not
/// comply with the SSH format anyway. /// comply with the SSH format anyway.
fn extend_usize(&mut self, u: usize) { fn extend_usize(&mut self, u: usize) {

View File

@ -235,6 +235,13 @@
hooks = hooks =
{ {
alejandra.enable = true; alejandra.enable = true;
typos = {
enable = true;
settings = {
verbose = true;
write = true;
};
};
codespell = { codespell = {
enable = true; enable = true;
entry = "${lib.getExe pkgs.codespell} -w"; entry = "${lib.getExe pkgs.codespell} -w";