Skip to content

chore(lint): enable clippy::indexing_slicing - #8

Merged
tupe12334 merged 1 commit into
mainfrom
clippy/enable-indexing_slicing
Jun 19, 2026
Merged

tupe12334 merged 1 commit into
mainfrom
clippy/enable-indexing_slicing

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Enable clippy::indexing_slicing

Closes #7

What

Adds indexing_slicing = "deny" to [lints.clippy] in lib/Cargo.toml and fixes the three resulting violations.

Why

The crate already denies unwrap_used, expect_used, panic, and unreachable — a "must not panic" policy. Direct indexing (a[i], body["key"]) is the remaining common panic source not covered by those. It is risky here because the installer parses untrusted network input (GitHub API JSON, checksums-sha256.txt); malformed input should yield an Err, never a panic. The lint forces fallible accessors that return Option.

Changes (src/github.rs)

  • body["tag_name"] → body.get("tag_name").and_then(Value::as_str) — missing key now flows to the existing no stable release found error instead of relying on Value::Null indexing.
  • Checksum parsing: replaced splitn(2,..).collect::<Vec<_>>() + parts[0]/parts[1] indexing with line.split_once(char::is_whitespace). Identical behavior, no indexing.

Verification

  • cargo clippy --all-targets — passes (0 warnings)
  • cargo build — passes
  • cargo test — 67 passed, 0 failed

Single lint, focused diff. No other lints touched; nothing merged or pushed to main.


This pull request was opened by the "Clippy lint improvements → issue + PR (Rust repos) → Slack" routine of moadim. cc @tupe12334

Deny direct indexing/slicing, which panics on out-of-bounds access.
This completes the crate's no-panic lint family (unwrap_used,
expect_used, panic, unreachable) by closing the remaining common
panic source. Especially important here since the installer parses
untrusted GitHub API JSON and checksum files from the network.

Fixes the three resulting violations in src/github.rs by switching
to fallible accessors (Value::get, split_once) with identical
behavior.

Closes #7

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tupe12334
tupe12334 merged commit 92a4310 into main Jun 19, 2026
2 checks passed
@tupe12334
tupe12334 deleted the clippy/enable-indexing_slicing branch June 19, 2026 01:10
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.

Enable clippy::indexing_slicing lint

1 participant