Gate: no-duplication
No code block appears copied in two places.
| Property | Value |
|---|---|
| Checker | duplication |
| Confronts | code |
| Blocking by default — new project | no — informs |
| Blocking by default — existing project | no — informs |
How it measures
Section titled “How it measures”The native check behind no-duplication. It runs jscpd once per scan and reads its JSON report,
which lists every clone with both files and their lines, instead of reading jscpd’s exit code. jscpd
exits 0 with any duplication unless a threshold is configured, so a gate that read the exit code
approved what it did not measure: in the reference app, 35 clones (1.17% of the lines), exit 0, and
check --all announced the gate “clean, ready to become blocking”.
Each file gets its own verdict. A file that holds a copy fails, naming the other side of each clone
and the lines; every other file passes. With --changed only the files of the change are judged,
so a commit answers for the clones it touches; jscpd still scans the whole project, because a new
copy only exists relative to its original.
The calibration is the project’s .jscpd.json, which jscpd reads by itself (minLines,
ignore, jscpd:ignore-start markers). Its threshold keeps jscpd’s meaning: the percentage of
duplicated lines the project tolerates.
Declaring it
Section titled “Declaring it”gates: - name: no-duplication on: [code] check: duplication