Skip to content

Commit 6f83928

Browse files
committed
chore: add cargo fmt and clippy to pre-commit hooks
fix: apply clippy suggestions (search_is_some in tests, fmt in main.rs) Assisted-by: Claude Code (Claude Sonnet 4.6)
1 parent fd9c719 commit 6f83928

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

.config/pre-commit.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ repos:
1919
hooks:
2020
- id: typos
2121
args: [--write-changes, --force-exclude, --config, .config/typos.toml]
22+
- repo: local
23+
hooks:
24+
- id: fmt
25+
name: cargo fmt
26+
language: system
27+
entry: cargo fmt --all --
28+
types: [rust]
29+
pass_filenames: false
30+
- id: clippy
31+
name: cargo clippy
32+
language: system
33+
entry: cargo clippy --all-targets --all-features -- -D warnings
34+
types: [rust]
35+
pass_filenames: false
2236
- repo: https://github.com/crate-ci/committed
2337
rev: v1.1.10
2438
hooks:

crates/git-ledger/src/tests.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ fn update_delete_field() {
175175
)
176176
.unwrap();
177177

178-
assert!(updated.fields.iter().find(|(k, _)| k == "status").is_none());
179-
assert!(updated.fields.iter().find(|(k, _)| k == "title").is_some());
178+
assert!(!updated.fields.iter().any(|(k, _)| k == "status"));
179+
assert!(updated.fields.iter().any(|(k, _)| k == "title"));
180180
}
181181

182182
#[test]
@@ -295,15 +295,9 @@ fn delete_nested_field() {
295295
.unwrap();
296296

297297
// The nested field should be gone
298-
assert!(
299-
updated
300-
.fields
301-
.iter()
302-
.find(|(k, _)| k == "meta/priority")
303-
.is_none()
304-
);
298+
assert!(!updated.fields.iter().any(|(k, _)| k == "meta/priority"));
305299
// The non-nested field should remain
306-
assert!(updated.fields.iter().find(|(k, _)| k == "title").is_some());
300+
assert!(updated.fields.iter().any(|(k, _)| k == "title"));
307301
}
308302

309303
#[test]

crates/git-metadata/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ fn run(cli: &Cli) -> Result<(), Box<dyn std::error::Error>> {
9191

9292
if !allow_empty
9393
&& let Some(ref c) = content
94-
&& c.is_empty() {
95-
return Err("refusing to add empty content (use --allow-empty)".into());
96-
}
94+
&& c.is_empty()
95+
{
96+
return Err("refusing to add empty content (use --allow-empty)".into());
97+
}
9798

9899
let opts = MetadataOptions {
99100
shard_level: *shard_level,

0 commit comments

Comments
 (0)