Skip to content

chore: internal cleanup and correctness polish - #31

Merged
Arkptz merged 7 commits into
mainfrom
chore/polish
Apr 22, 2026
Merged

chore: internal cleanup and correctness polish#31
Arkptz merged 7 commits into
mainfrom
chore/polish

Conversation

@Arkptz

@Arkptz Arkptz commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace guarded .unwrap() / .expect() calls in production code with pattern matching and ? propagation
  • Lazy-init the OpenAPI version regex via LazyLock instead of runtime .expect()
  • Extract duplicated is_numeric_string / is_uuid helpers into a shared type_hints module
  • Improve schema inference: sample up to 3 array elements (emit oneOf on divergence) and require 3+ dynamic keys before classifying an object as a dict (prevents false positives on HTTP status-code-keyed objects)
  • Emit warnings on previously silent drops: unreadable directory entries and malformed --tags-overrides JSON
  • Add #![deny(clippy::indexing_slicing)] at the crate level; production code uses .get() / .first()

Type of Change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Documentation update
  • Refactoring / internal cleanup
  • CI / build / tooling

Checklist

  • cargo fmt --all clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • cargo test passes locally
  • Added or updated tests for the change
  • Updated README / CLI help text if user-facing behavior changed
  • Added entry to CHANGELOG.md under [Unreleased] (if user-facing)
  • Used conventional commit style in commit messages (feat:, fix:, docs:, etc.)

Testing

cargo fmt --all --check     # clean
cargo clippy --all-targets -- -D warnings  # clean
cargo test --lib            # 233 passed
cargo publish --dry-run     # passes

Related Issues

Internal cleanup — no linked issues.

Arkptz added 7 commits April 23, 2026 00:21
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.
@Arkptz
Arkptz merged commit 361cf2a into main Apr 22, 2026
12 checks passed
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