Skip to content

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

Open
Metbcy wants to merge 1 commit into
mainfrom
refactor/typosquat-split
Open

refactor(typosquat): split typosquat.rs into a submodule directory (#69)#71
Metbcy wants to merge 1 commit 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

Copy link
Copy Markdown

Coverage report

Line coverage: 83.1% (8800 / 10586 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.

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