Duplication
necro scan detects copy-paste clones — duplicated code, even when the copy
renamed its variables. Clones appear in a Duplication section (and a
duplication array in --json).
Duplication (1 clone) 43 tokens duplicated: src/a.ts:1-6, src/b.ts:1-6How it works
Section titled “How it works”necro tokenizes each file with the same tree-sitter parser the complexity detectors use — no jscpd or other external tool. Before matching, it normalizes the tokens:
- identifiers collapse to a single
IDtoken, - literal values collapse to
LIT, - comments and whitespace are dropped,
- keywords, operators, and punctuation keep their kind.
It then finds the longest normalized token sequences shared by two or more places. Because names and literals are erased, a block copied and then renamed (a Type-2 clone) still matches:
function add(a, b) { const sum = a + b; return sum; } // ← reported asfunction plus(x, y) { const total = x + y; return total; } // one clone groupEach clone is reported once, as its maximal region — not as a swarm of overlapping fragments.
Tuning
Section titled “Tuning”A sequence must be at least minTokens long to count (default 50). Lower it to
catch smaller clones, raise it to focus on large ones:
{ "duplication": { "minTokens": 80 }}