Repository navigation
chore(lint): enable clippy::indexing_slicing - #8
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable
clippy::indexing_slicingCloses #7
What
Adds
indexing_slicing = "deny"to[lints.clippy]inlib/Cargo.tomland fixes the three resulting violations.Why
The crate already denies
unwrap_used,expect_used,panic, andunreachable— 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 anErr, never a panic. The lint forces fallible accessors that returnOption.Changes (
src/github.rs)body["tag_name"]→body.get("tag_name").and_then(Value::as_str)— missing key now flows to the existingno stable release founderror instead of relying onValue::Nullindexing.splitn(2,..).collect::<Vec<_>>()+parts[0]/parts[1]indexing withline.split_once(char::is_whitespace). Identical behavior, no indexing.Verification
cargo clippy --all-targets— passes (0 warnings)cargo build— passescargo test— 67 passed, 0 failedSingle 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