Skip to content

refactor(typosquat): split typosquat.rs into a submodule directory (#69) - #71

Merged
Metbcy merged 3 commits into
mainfrom
refactor/typosquat-split
Jul 2, 2026
Merged

refactor(typosquat): split typosquat.rs into a submodule directory (#69)#71
Metbcy merged 3 commits into
mainfrom
refactor/typosquat-split

Conversation

@Metbcy

@Metbcy Metbcy commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Splits the 1197-LOC src/enrich/typosquat.rs into a src/enrich/typosquat/ submodule directory, the next file over the 1000-LOC soft cap after the #57 series. Closes #69.

Pure mechanical move: no logic, threshold, or string literal changed. The layout mirrors PR #64 (maintainer/).

Layout

File LOC Responsibility
mod.rs 163 Crate doc, TyposquatFinding, the embedded list constants and tuning constants, and the public enrich / enrich_with_threshold / check_one entry points
ecosystem.rs 102 The SupportedEcosystem enum and its list / separator / cache mappings
canonical.rs 90 Name canonicalization and match-form extraction
matching.rs 132 Jaro-Winkler scoring with suffix boost, plus the Maven Levenshtein path
lists.rs 89 Reference-list loading (embedded snapshots, XDG cache, dedup sets)
tests.rs 665 The #[cfg(test)] mod tests block, moved verbatim

Why

typosquat.rs was the second-largest non-test file over the soft cap. The split separates the scoring algorithms, ecosystem handling, and list loading into their own files per the budget rule in docs/src/architecture.md.

Compatibility

The public surface stays reachable at the same paths (crate::enrich::typosquat::{TyposquatFinding, enrich, enrich_with_threshold, SIMILARITY_THRESHOLD}). pub mod typosquat; in src/enrich/mod.rs is unchanged. Cross-module helpers are pub(super); the include_str! paths for the embedded lists were repointed one level deeper.

Testing

  • cargo build --all-targets --all-features (RUSTFLAGS="-D warnings"): clean
  • cargo clippy --all-targets --all-features -- -D warnings: clean
  • cargo test --all-features: 441 lib + 36 cli + 9 integration + 7 real_world + 1 doc, all pass
  • cargo fmt --all --check: clean

Closes #69.

src/enrich/typosquat.rs was 1197 LOC, over the 1000-LOC soft cap in the
module size budget. Split it into src/enrich/typosquat/ mirroring the
enrich/maintainer/ split from the #57 series: mod.rs owns the
TyposquatFinding type, the embedded list constants, and the public
enrich entry points, with ecosystem.rs (the SupportedEcosystem enum),
canonical.rs (name normalization), matching.rs (Jaro-Winkler and Maven
Levenshtein scoring), lists.rs (reference-list loading), and tests.rs.

Pure mechanical move, no behavior change. The public surface stays
reachable at crate::enrich::typosquat::* (TyposquatFinding, enrich,
enrich_with_threshold, SIMILARITY_THRESHOLD) and pub mod typosquat; in
enrich/mod.rs is unchanged. Cross-module helpers are pub(super).

Closes #69.
@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown

Coverage report

Line coverage: 82.4% (8306 / 10080 lines)

Full lcov report available as workflow artifact coverage-lcov: download from this run.

v0.9.8 introduces this report; --fail-under-lines will be added once coverage is visible across 2–3 releases.

Metbcy and others added 2 commits July 2, 2026 18:27
cargo-deny's advisories check started failing on this branch after
RUSTSEC-2026-0190 was published against anyhow <1.0.103 (unsoundness in
Error::downcast_mut when an error carries added context, causing UB via
a bad mutable-reference retag). The advisory DB lists patched = >=1.0.103.

Lockfile-only bump; the manifest constraint (anyhow = "1") already allows
it. Full lib suite green (441 passed) on the updated dep.
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

SBOM diff

Change Count
Added 0
Removed 0
Version changed 1
License changed 0

Version changed (1)

Show details
Ecosystem Name Before After
cargo anyhow 1.0.102 1.0.103

False positive? Report it · Suppress a finding? Comment /bomdrift suppress <ID> (requires the comment-suppress sub-action) · Docs

@Metbcy
Metbcy merged commit 00bf4a0 into main Jul 2, 2026
11 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.

refactor(typosquat): split src/enrich/typosquat.rs into a submodule directory (#57 follow-up)

1 participant