Verification · Static analysis
Duplicate code detection
Finds copied blocks so a fix in one copy is not missed in the others, and flags new code that re-implements an existing helper.
Sub-techniques
-
Token clone detection
V1011.001Report token-identical or near-identical blocks above a size threshold.
-
Semantic reuse check
V1011.002Search the codebase for an existing function that does what the new code does, by embedding or by name.
How to build it
- Run a clone detector with a minimum token count that ignores tests and generated code.
- Report only clones introduced by the change.
- For reuse, index function signatures and docstrings and query with each new function.
Signals in a repository
- .jscpd.json or a cpd task in the build.
- Review comments asking to reuse an existing helper point at where this is missing.