chore: internal cleanup and correctness polish - #31
Merged
Merged
Conversation
Replace .unwrap() after is_some() guard in mitmproxy_reader with if-let. Replace .expect() in tnetstring length parser with ? propagation. Use .first()/.get() for header pair access instead of direct indexing.
Replace runtime .expect("valid regex") with a LazyLock<Regex> static,
compiled once on first use.
Deduplicate type-hint helpers that existed in both schema.rs and path_matching.rs into a new crate-internal type_hints module.
Array inference now samples up to 3 elements and emits oneOf when types diverge instead of using only the first element. Dict classification now requires 3+ dynamic keys or mixed-type values, preventing false positives on objects keyed by HTTP status codes.
HAR and mitmproxy directory scanners now log a warning when a directory entry cannot be read instead of silently dropping it. parse_tags_overrides now emits a warning when --tags-overrides JSON is malformed instead of silently ignoring it.
Add #![deny(clippy::indexing_slicing)] to lib.rs. Production code uses .get()/.first() instead of direct indexing; test modules are allowed since panics there are acceptable.
…_slicing lint The loop iterates with mutable remove, so direct indexing worked but trips the crate-level deny we just added. Use .get() with Option handling for safety-first access pattern.
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.
Summary
.unwrap()/.expect()calls in production code with pattern matching and?propagationLazyLockinstead of runtime.expect()is_numeric_string/is_uuidhelpers into a sharedtype_hintsmoduleoneOfon divergence) and require 3+ dynamic keys before classifying an object as a dict (prevents false positives on HTTP status-code-keyed objects)--tags-overridesJSON#![deny(clippy::indexing_slicing)]at the crate level; production code uses.get()/.first()Type of Change
Checklist
cargo fmt --allcleancargo clippy --all-targets --all-features -- -D warningscleancargo testpasses locallyCHANGELOG.mdunder[Unreleased](if user-facing)feat:,fix:,docs:, etc.)Testing
Related Issues
Internal cleanup — no linked issues.