Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWhen Mahiro Hirakawa’s build detector flagged a check he had just written, he removed the repeated implementation instead of weakening the rule. The detector had found the same code structure under different local names and string values. Hirakawa then checked the refactor separately by comparing its emitted output with the pre-refactor run.
Why did the detector flag two checks that looked different?
Hirakawa says the detector compared normalized code shapes using a ten-line window. One check used verdict_kind and verdict_unit; another used term_kind and term_unit. The local names differed, as did string values, but the detector erased string literals and normalized accessor calls. What remained was a matching structure.
As an Amazon Associate I earn from qualifying purchases.
That is why a review focused on names or a straightforward text diff can miss duplication: the surface text changes while the sequence of operations stays the same. Hirakawa’s description is an account of his project and detector, not an independently audited evaluation.
Should you change the detector or the code?
Hirakawa considered three responses. They differ in whether they remove the repeated implementation or suppress findings that might matter later.
#1 Best Overall
| Response | Effect on the current finding | Effect on future findings | Behavior check |
|---|---|---|---|
| Except the two files | Suppresses the finding in those files; the repeated implementation remains. | Could hide later duplication in the same files. | Does not establish whether behavior changed. |
| Increase the window from ten to eleven lines | Changes the detector threshold rather than removing the repeated implementation. | Could miss future cases that fall below the larger window. | Does not establish whether behavior changed. |
| Deduplicate the implementation | Removes the repeated structure while retaining the rule. | Leaves the detector able to flag later cases under its existing setting. | Requires a separate check that behavior was preserved. |
He chose the third option. His reasoning was that a file exception or a larger detection window would make future findings less likely within the affected scope, while deduplication required a one-time refactor. He described the rule as a copy ban within the project tree and noted the temptation to waive a finding in code he had just written.
How did he remove the repeated code?
Hirakawa says the fix declared four repeated cells once and read them through a map. That replaced the duplicated checks with a shared implementation, rather than teaching the detector to ignore them. The article does not provide enough detail to reproduce the exact code or map structure, so the useful lesson is the refactoring shape: centralize the repeated values and have the checks read from that shared declaration.
How can you check that a deduplication preserved behavior?
A duplication count answers whether the detector still sees duplication according to its rules. It does not answer whether the refactored code emits the same results. Hirakawa treated those as separate questions: first, whether the repeated structure was gone; second, whether the output remained unchanged.
- Check the structural result: Hirakawa reports
OK_SCAFFOLD faces=8/8 dup=0andscaffold tests 67/67for his project run. - Check behavior independently: He reports
OK_ALL controls=24and says every emitted line was byte-identical to the pre-refactor run.
These are results reported by Hirakawa for his own project and run, not general benchmarks or independently verified results. The byte-for-byte comparison is the part that addresses behavioral preservation; dup=0 alone cannot do that.
Rank #3
What should you take from this case?
When a detector catches code that looks new, inspect the structure beneath the names and literals before deciding the rule is too strict. If the same implementation is genuinely repeated, deduplicate it and preserve a separate behavior check. As Hirakawa puts it, “A dedup refactor needs a behaviour-preservation control, not a duplication count.”
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




