June 19, 2026
Copy, paste, panic
Ask HN: How do you separate intentional test boilerplate from real duplication?
Code cops vs test clutter: HN argues over when copy-paste is actually fine
TLDR: An open-source developer asked Hacker News how a code checker can tell useful repeated test code from bad copy-paste. Commenters split between “just ignore test files” and “no, repeated tests can reveal sloppy design,” turning a niche tooling question into a broader fight over what clean code really means.
A deceptively nerdy Ask HN thread turned into a mini courtroom drama over a surprisingly relatable question: when is repeated code in tests just harmless routine, and when is it a sign your project is getting messy? The developer behind an open-source duplicate finder wanted help teaching the tool the difference, and the crowd immediately split into camps.
One side came in with pure “just keep it simple” energy. Why not just skip tests? one commenter basically asked, pointing out that in some languages test files are clearly labeled, so the detector could simply ignore them and move on. Another offered the classic tidy-up answer: if tests keep repeating the same setup, wrap that shared part in a helper function and stop the madness. That’s the practical camp.
But then came the more dramatic twist: some users argued that repeated tests are not always innocent boilerplate at all—they can be a red flag that the tests themselves need a makeover. One commenter said duplicate warnings in test folders often pushed them toward cleaner, easier-to-read parameterized tests instead. In other words: the tool might be annoying, but it may also be right.
The funniest vibe in the thread was the low-key confusion. One user bluntly asked, “What is a structural detector?” which perfectly captured the mood of anyone watching this debate spiral from “simple feature request” into “philosophy of testing.” The real consensus? Everyone wants less noise, but nobody agrees on where useful repetition ends and lazy copy-paste begins.
Key Points
- •The post is about an open-source duplicate-code detector facing a feature request related to test-code duplication.
- •The author says tests often repeat scenarios intentionally, causing structural detectors to flag them as duplicated code.
- •The article states that developers generally do not want test code removed just because similar patterns appear across tests.
- •The current challenge is that tools cannot clearly distinguish intentional repetition in tests from unwanted duplication.
- •The author proposes human-in-the-loop handling, similar to linter acceptance workflows, and links the dupehound repository and a detailed GitHub issue.