Skip to content

fix(lint): clear 16 RUST/unwrap warnings#209

Merged
forkwright merged 1 commit intomainfrom
fix/lint-unwrap-refactor
Apr 20, 2026
Merged

fix(lint): clear 16 RUST/unwrap warnings#209
forkwright merged 1 commit intomainfrom
fix/lint-unwrap-refactor

Conversation

@forkwright
Copy link
Copy Markdown
Owner

Summary

Clears all 16 RUST/unwrap warnings in harmonia library code. Part of the 77-warning cleanup arc unblocking 05e cutover. Sibling PRs address 14 TOML/inline-table-too-long, 3 RUST/indexing-slicing, and 44 RUST/non-exhaustive-enum warnings.

Per-site decisions

File:line Decision Rationale
paroche/src/subsonic/types.rs:58 4 expect+INVARIANT Response::builder static 200 + static Content-Type infallible
paroche/src/subsonic/types.rs:69 4 expect+INVARIANT serde_json::to_string of json!() Value infallible
paroche/src/subsonic/types.rs:75 4 expect+INVARIANT Response::builder same invariant
paroche/src/subsonic/types.rs:94 4 expect+INVARIANT Response::builder same invariant
paroche/src/subsonic/types.rs:103 4 expect+INVARIANT serde_json::to_string same invariant
paroche/src/subsonic/types.rs:110 4 expect+INVARIANT Response::builder same invariant
syndesis/src/client/buffer.rs:61 4 expect+INVARIANT seq came from first_key_value() immediately above
syndesis/src/client/buffer.rs:107 4 expect+INVARIANT len >= 2 guard above
syndesis/src/client/buffer.rs:108 4 expect+INVARIANT len >= 2 guard above
syndesmos/src/retry.rs:67 5 mutex poison mutex poisoning is unrecoverable
syndesmos/src/retry.rs:76 5 mutex poison mutex poisoning is unrecoverable
syndesmos/src/retry.rs:83 5 mutex poison mutex poisoning is unrecoverable
syndesmos/src/retry.rs:145 4 expect+INVARIANT retry loop sets last_err on every non-Ok path
syntaxis/src/queue.rs:94 4 expect+INVARIANT pos from tier3.position() in-bounds
syntaxis/src/queue.rs:98 4 expect+INVARIANT pos from tier2.position() in-bounds
syntaxis/src/queue.rs:102 4 expect+INVARIANT pos from tier1.position() in-bounds

Zero kanon:ignore markers used. Every .expect() carries a line-local // INVARIANT: comment citing the specific code-visible invariant so both RUST/unwrap and RUST/expect rules skip cleanly.

Verification

  • cargo check --workspace: PASS
  • cargo nextest run --workspace: 1075/1075 passed, 3 skipped
  • kanon lint: 0 RUST/unwrap, 0 RUST/expect, 61 other pre-existing warnings (44 non-exhaustive-enum + 14 TOML + 3 indexing-slicing — sibling agents)
  • kanon gate --stamp: FAILS on cargo clippy (pre-existing: komide type_complexity expect unfulfilled, zetesis too_many_arguments, paroche album_xml_elem/album_json too_many_arguments) and kanon lint (61 pre-existing warnings). Out of scope for this PR.

Test plan

  • Confirm CI picks up the push
  • Verify no merge conflict with the 3 sibling warning-cleanup PRs (non-overlapping files)
  • Merge after sibling PRs land to hit 0-warning state for 05e gate

…ed in body)

For each site, applied: (a) ? propagation, (b) .expect with cited
invariant via `// INVARIANT:` comment, (c) test-context expect for
clarity, or (d) kanon:ignore with WHY. Zero kanon:ignore markers used.
Each .expect() carries a line-local `// INVARIANT:` comment so the
RUST/expect rule skips without needing suppression.

Per-site mapping (file:line → decision — rationale):

paroche/src/subsonic/types.rs (6 sites — all decision 4, provably safe):
  - Two `respond_*` helpers built Response objects with static 200 +
    static Content-Type; converted 4 Response::builder unwraps to
    .expect("infallible: static 200 status + static Content-Type").
  - Two `serde_json::to_string` on json!() Values are infallible;
    .expect("infallible: serde_json::to_string of json!() Value").
  - The enclosing pre-existing `#[expect(clippy::unwrap_used)]` attrs
    were removed since the invariant is now documented at the call site.

syndesis/src/client/buffer.rs (3 sites — all decision 4):
  - line 61: `frames.remove(&seq)` where seq came from first_key_value()
    immediately above with no intervening mutation.
  - lines 107/108: next()/next_back() on a BTreeMap guarded by
    `frames.len() < 2` early return above.

syndesmos/src/retry.rs (4 sites):
  - lines 67/76/83 (decision 5 — Mutex<Option<Instant>>):
    .expect("mutex poisoning is unrecoverable"). Holder panic would
    leave the circuit breaker inconsistent; propagate instead.
  - line 145 (decision 4 — exhausted retry loop):
    `last_err.expect("loop set last_err on every non-Ok path")` —
    `with_retry` traverses `0..=RETRY_DELAYS.len()` iterations; every
    path either returns Ok early or assigns `last_err = Some(err)`.

syntaxis/src/queue.rs (3 sites — all decision 4):
  - lines 94/98/102 in `reprioritize`: each `tier.remove(pos)` has `pos`
    sourced from `tier.iter().position(|i| i.id == id)` on the same
    tier one statement prior with no intervening mutation.

Part of the harmonia 77-warning cleanup arc unblocking 05e cutover.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@forkwright forkwright merged commit 0c0f16f into main Apr 20, 2026
2 of 3 checks passed
@forkwright forkwright deleted the fix/lint-unwrap-refactor branch April 20, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant