feat: reduce unused-code and duplicate-code false positives#18
Merged
Conversation
- duplicate-code --max-warnings now gates on distinct duplicated regions: jscpd pairs whose ranges overlap on either side are merged (union-find), collapsing overlapping re-reports and N-file patterns reported as N-1 pairs. Failure output shows both the deduped and raw counts. Benchmark: 106 raw clones -> 78 distinct regions on a real repo. - unused-code failures now print false-positive advice: check for dynamic loading (directory scan + require(), glob-registered ORM entities) and system binaries before deleting; suppress via knip entry/ignoreBinaries. - verifyx init detects system binaries invoked by package.json scripts that knip's IGNORED_GLOBAL_BINARIES doesn't cover (uv, az, python, terraform, ...) and adds them to knip ignoreBinaries.
PatrickDinh
marked this pull request as ready for review
July 21, 2026 06:19
staff0rd
reviewed
Jul 21, 2026
staff0rd
left a comment
Member
There was a problem hiding this comment.
Code review summary
Findings: 2 (blocker 0, major 0, minor 1, nit 1)
This is a focused, well-tested change that reduces false positives in the unused-code and duplicate-code checks (deduping jscpd clone regions, adding system-binary detection for knip's ignoreBinaries, and surfacing failure advice). Neither reviewer found a blocking or major defect; the only substantive issue is a narrow gap in shell-script binary detection that leaves one class of invocations unsuppressed.
Findings
- minor: Binary detection misses command/process substitutions inside shell redirects
- nit: jscpd report shape unverified against live tool output
staff0rd
approved these changes
Jul 21, 2026
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
duplicate-code --max-warningsnow gates on distinct duplicated regions instead of raw jscpd clones, and its failure output shows both counts.unused-codefailures now include guidance on recognising and suppressing knip false positives before deleting code.verifyx initadds system binaries invoked bypackage.jsonscripts (uv,az,python, …) to knip'signoreBinaries.Why
Auditing a real consuming repo showed jscpd reporting the same duplication several times over, and knip flagging runtime-loaded files as unused — noise that inflates warning budgets and tempts an agent into deleting load-bearing code.
How
Clones merge when their ranges overlap on either side (union-find over pairs); the deduped count can only be lower than the raw one, so existing
--max-warningsgates cannot newly fail. TheignoreBinariescandidates are curated against knip'sIGNORED_GLOBAL_BINARIESso the scaffold never writes redundant entries that--treat-config-hints-as-errorswould then flag.