You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(server): close .expect("TODO") anti-pattern
Eliminates the bulk-rewrite anti-pattern (.unwrap() -> .expect("TODO: handle
error") substitution that gives identical panic behaviour while pretending to
mark debt). 35 sites cleared across 10 Rust files.
Production restructures (5 sites, all in working tree before this commit):
- core.rs `html_to_markdown`: two `Selector::parse(...).expect()` calls reworked
to `if let Ok(selector) = Selector::parse(...)` so a malformed selector is
structural, not a panic. Mirrors the pattern already used elsewhere in the
same function. (policy a/c-style, structural pivot.)
- core.rs `html_to_markdown` body fallback: `if let Some(body) ... else` over a
`Selector::parse("body").expect()` rewritten to `match ... .ok().and_then(...)`
so both the parse failure and empty selection cleanly fall back to root text.
- core.rs `html_to_json` heading loop: same `Selector::parse` if-let pivot.
- monitoring.rs `snapshot`: `if !durations.is_empty() { ... durations.iter()
.max().expect() ... .min().expect() ... }` collapsed into a single
`iter().copied().fold(None, ...)` with `let-else` continue, removing the
`.expect()` pair entirely. (policy b, structural restructure on Option.)
Test sites (30 sites, mass `replace_all` to `.unwrap()` after verifying every
call sat below the file's `#[cfg(test)]` line): auth.rs (1), core.rs (7),
document_store.rs (3), formats/mod.rs (4), formats/toml.rs (1), formats/xml.rs
(2), formats/yaml.rs (2), http.rs (7), websocket.rs (3).
Test counts unchanged: 152 passed / 0 failed / 0 ignored before and after.
`cargo build` clean (pre-existing unused-variable warnings only).
Pattern proven on valence-shell (~512 sites) and 3 estate-batch-1 peers
(reposystem 33, vexometer 44, double-track-browser 47).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments