Repository navigation
feat(rules): duplicate-items reports function bodies written twice - #33
Draft
PiquelChips wants to merge 1 commit into
Draft
PiquelChips wants to merge 1 commit into
PiquelChips wants to merge 1 commit into
Conversation
3 tasks done
PiquelChips
force-pushed
the
feat/rule-route-literals
branch
from
November 22, 2026 22:18
8cc9f86 to
dafb8fa
Compare
PiquelChips
force-pushed
the
feat/rule-duplicate-items
branch
from
November 22, 2026 22:19
dc7c099 to
25d3636
Compare
A function body outside test code with at least 50 tokens fails when it repeats another token for token once identifiers are renamed in the order they appear. The walk passes each function with a body to Inspect, and a body's shape is hashed. Below 50 tokens, the three repositories' copies are boilerplate rather than logic to share.
PiquelChips
force-pushed
the
feat/rule-duplicate-items
branch
from
November 22, 2026 22:20
25d3636 to
bc0c299
Compare
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 and why
Code isn't duplicated, even small functions: shared behaviour lives once, on its owning type (PR2). Copies with renamed variables slip past review, and nothing checked for them.
duplicate-itemsfails on a function body outside test code that repeats another one, token for token, once identifiers are renamed in the order they appear, when the body holds at least 50 tokens.$0,$1, …). Bodies that differ only in names, including the path constant or method they call, share a shape. The shape is hashed. A copy names its first occurrence,path:line.inline-limitsfeat(rules): inline-limits makes Durations with literals named constants #30 defines it) and generated files;Inspect::function.--fix: merging copies takes judgement. The cleanup skill judges what is left below the threshold.Stacked on #32.
Testing
just check-changed feat/rule-route-literalspasses.Choosing N, on detached worktrees of each repository's
origin/main(since removed), counting copies (piqueld / sourceorigin / DirkEngine):At 40, boilerplate comes in: two-route
routes()routers in sourceorigin, andFromimpls across crates. At 50, every hit is logic written twice with one name changed:delete_secret/delete_stored_secret(only the store method differs), the fake Docker'sremove_service/remove_volume, and threepiquelctl envsubcommands'run. The one debatable copy istiming/timing_mut, a&/&mutaccessor pair that only a macro would share.schedule_deletion/purge_user(.schedulevs.purge), the admin invitation handlersresend/revoke,recover_page/undo_page,sign_out_page/unsubscribe_page,emails/passkeys, and twofrom_request_parts.frame_graph'sread_texture_fragment/read_texture_compute/read_transfer_src/write_transfer_dst(only the Vulkan constants differ), and twoto_eguiconversions (onlyPos2/Vec2differ).Cost: the rule takes about 1 s of a debug
cargo xtask standardon piqueld, where loading and parsing the files takes about 5 s.Checklist
just readme.)Rulevariant; no xtask change.)just check-changedpasses.Note
Written by Claude Opus 5.5 in Claude Code (via T3 Code)