Repository navigation
feat: per-path rules for scan thresholds - #37
Merged
Merged
Conversation
* rules: in .dupehound.yml overrides min-tokens/similarity or skips files by glob; first match wins * cross-rule clones are judged by the highest min-tokens among their files * one exact pass per distinct threshold; no rules = byte-identical output * rule shown in every format; --no-rules flag; validated with rule and line in errors Refs #36 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ PR title follows the required formatCurrent title: |
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.
What
Per-path rules in
.dupehound.yml(spec #36, approved). One threshold rarely fits a repo: test fakes of 20–40 tokens are invisible at 50, and 25 everywhere floods production.Before (one threshold, 50): the copied
EchoModelfake is not reported. After:Decisions
min-tokensamong its files (type-3: highestsimilarity). Independent of instance order, production is never reported below its own threshold, and test-only copies are still found because the lower threshold runs over the test files alone (the fake above is also insrc/app.py, which is at 50, so that copy is left out).min-tokens,similarity,skip. CLI--min-tokens/--similarityset the base and rules still apply;--no-rulesturns them off.rule,rule_min_tokens), sarif (properties.rule), github annotations.rules:is strict (unknown key, empty/malformed glob, threshold ≤ 0,skip+ override, duplicate name →rules[N] (line L): …, exit 2).scan:stays lenient so existing configs keep loading.Verification
--sincescope per pass, baseline hashes unchanged, invalid configs, all five formats.--no-rulesis byte-identical to v0.2.0's (integration/testdata/rules.norules.*.golden, recorded with the main binary).net(378 files): no rules byte-identical to main; with a tests rule at 25 the 225 clones touching production are identical (hash + locations), 6.2 s → 10.2 s, peak RSS +3%.go test -race ./..., golangci-lint, gofumpt, structlint, govulncheck clean; self-scan reports 0 clones.Backward compatibility (no
rules:)v0.2.0 and this branch, built from source, run against dupehound, structlint, loadout, tacomex-8bit-shop, switchyard, qorder-app, replayraccoon and quasar (Go, TS, Python, Rust), each with its own
.dupehound.yml:--dead-code,--scope function,--git-churn,--since,--staged, low-memory mode (--max-memory 120M), and empty, comment-only and unknown-key configs.--write-baselinefiles identical; a v0.2.0 baseline suppresses the same clones (same known/new counts) with the new binary.gauntlet checkoutput identical. qorder-app (804 files, 134k lines), 7 runs each: 7.22 s vs 7.30 s mean, same peak RSS.Refs #36