From 6ddc9b83bf5428eba7ca81caa567bae5672120ab Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Wed, 3 Jun 2026 20:53:50 -0700 Subject: [PATCH] fix: clippy single_match in heph-tui + add clippy pre-commit hook CI on main failed on a clippy::single_match lint in the heph-tui sidebar key handler. Rewrite as `if let`. Also add a `cargo clippy -D warnings` prek hook mirroring cargo-fmt, so lints are caught locally before CI (prek previously only ran cargo fmt). Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/heph-tui/src/main.rs | 9 +++++---- docs/changelog.d/+clippy-prek-hook.infra.md | 1 + docs/changelog.d/+fix-clippy-single-match.bugfix.md | 1 + prek.toml | 12 ++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 docs/changelog.d/+clippy-prek-hook.infra.md create mode 100644 docs/changelog.d/+fix-clippy-single-match.bugfix.md diff --git a/crates/heph-tui/src/main.rs b/crates/heph-tui/src/main.rs index 6d8b85a..3f2d834 100644 --- a/crates/heph-tui/src/main.rs +++ b/crates/heph-tui/src/main.rs @@ -186,10 +186,11 @@ fn handle_key(app: &mut App, key: KeyEvent) -> Option app.begin_delete(), _ => {} }, - Focus::Sidebar => match key.code { - KeyCode::Char('D') => app.begin_delete_project(), - _ => {} - }, + Focus::Sidebar => { + if let KeyCode::Char('D') = key.code { + app.begin_delete_project() + } + } }, } None diff --git a/docs/changelog.d/+clippy-prek-hook.infra.md b/docs/changelog.d/+clippy-prek-hook.infra.md new file mode 100644 index 0000000..a3ed71b --- /dev/null +++ b/docs/changelog.d/+clippy-prek-hook.infra.md @@ -0,0 +1 @@ +Add a `cargo clippy -D warnings` pre-commit hook so lints are caught locally before CI. diff --git a/docs/changelog.d/+fix-clippy-single-match.bugfix.md b/docs/changelog.d/+fix-clippy-single-match.bugfix.md new file mode 100644 index 0000000..0548d68 --- /dev/null +++ b/docs/changelog.d/+fix-clippy-single-match.bugfix.md @@ -0,0 +1 @@ +Fix `clippy::single_match` lint in heph-tui sidebar key handling (CI failure on main). diff --git a/prek.toml b/prek.toml index c6a3a8f..ebd8d1a 100644 --- a/prek.toml +++ b/prek.toml @@ -97,6 +97,18 @@ language = "system" files = '\.rs$' pass_filenames = false +# Rust linting - cargo clippy over the whole workspace, denying warnings to +# match CI (`dagger call check` / .forgejo/scripts/build run the same command). +# Catches lints (e.g. clippy::single_match) before they reach CI. Uses the +# system toolchain; runs whenever a .rs file is staged. +[[repos.hooks]] +id = "cargo-clippy" +name = "cargo-clippy" +entry = "cargo clippy --all-targets --all-features -- -D warnings" +language = "system" +files = '\.rs$' +pass_filenames = false + # GitHub/Forgejo Actions workflow linting [[repos]] repo = "https://github.com/rhysd/actionlint"