Address CodeRabbit review: document the panel scan's blind spots

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-10-21 12:43:58 +02:00
1 parent b45be327b6
commit 9b21358035
2 files changed
+26 -3

No files matched your search

+6 -1
View File
@@ -307,7 +307,12 @@ widget function that takes a `Ui` and returns `bool`. Inside one it fails, with
direct document or session change: `active_mut()`, `Arc::make_mut` on a doc,
`session.undo/redo/select_layer/add_document/close(…)` or an assignment to a session field
(`app.session.tools.foreground = …`). Dispatch the command instead (`app.run`, `menus::invoke`).
The scanner is lexical and does not follow calls into helpers. Existing violations are listed in
A passing scan is not complete coverage. The scanner is lexical: it does not follow calls into
helpers, and it only recognises an `if` block (a `match` arm guard with a block counts) or a
`let` local holding a response, so a `match` on a response without such a guard, a response kept
in a struct field and tested later, or a closure callback is not checked. Preferences
(`edit_prefs`), shell view state (`app.ui`, the `UI_COMMANDS`) and switching the active document
are out of scope. Existing violations are listed in
`ALLOWLIST` in `xtask/src/panel_commands.rs` by file and function, each with its reason; an entry
that matches nothing any more is an error, so the list only shrinks.
+20 -2
View File
@@ -17,8 +17,11 @@
//! * test code is skipped: `*_tests.rs`, `tests.rs`, files under `tests/` and `#[cfg(test)]` items.
//!
//! Out of scope: preferences (`edit_prefs`), shell view state (`app.ui`, the `UI_COMMANDS`) and
//! switching the active document. Calls into helper functions are not followed, so a handler that calls a helper which mutates the
//! document passes; the check catches the inline pattern, which is how such shortcuts start.
//! switching the active document. Calls into helper functions are not followed, so a handler
//! that calls a helper which mutates the document passes; the check catches the inline pattern,
//! which is how such shortcuts start. Only `if` blocks (also a `match` arm guard with a block)
//! and `let` locals count as handlers: a `match` on a response without one, a response kept in a
//! struct field and tested later, or a closure callback is not scanned.
//!
//! Existing violations are listed in [`ALLOWLIST`] by file and enclosing function, each with the
//! reason it is still there. An entry that no longer matches anything is an error, so the list only
@@ -601,6 +604,21 @@ fn panel(app: &mut App, ui: &mut Ui) {
assert_eq!(v[0].line, 7);
}
#[test]
fn a_match_arm_guard_with_a_block_is_a_click_handler() {
let src = "
fn panel(app: &mut App, ui: &mut Ui) {
match ui.button(\"Hide\") {
r if r.clicked() => {
app.session.active_mut();
}
_ => {}
}
}
";
assert_eq!(lines(src), [(5, "panel".to_string())]);
}
#[test]
fn every_mutation_kind_and_trigger_is_caught() {
let src = r#"