@@ -6,16 +6,27 @@ Swift build caches, Android build output, and packaged helpers. No source exclus
66
77## Reproduce the comparison
88
9+ The table records source commit ` a16d4372376bf18eea3dff4cbe85e15fc68e7fc0 ` .
10+ It is an experiment record, not a target for later revisions. Files below the token minimum do
11+ not contribute to jscpd's analyzed-file count. Percentages are its duplicated-line metric,
12+ not unique lines to remove.
13+
14+ Use jscpd 5.4.2. To replay the recorded inputs without changing this checkout, extract only
15+ tracked source from that commit:
16+
917``` sh
1018pnpm install --frozen-lockfile
11- pnpm native-dupes:prototype
19+ pnpm exec jscpd --version
20+ native_dupes_source=" $( mktemp -d " ${TMPDIR:-/ tmp} /agent-device-native-dupes.XXXXXX" ) "
21+ git archive a16d4372376bf18eea3dff4cbe85e15fc68e7fc0 -- apple android linux \
22+ packages/platform-apple/src/core/__tests__/display-inventory.test.ts \
23+ packages/platform-apple/src/__tests__/simctl-facade.test.ts | tar -x -C " $native_dupes_source "
1224```
1325
14- Each variant scans ` apple/ ` , ` android/ ` , and ` linux/ ` , then scans the two TypeScript tests named in
15- the original report. JSON reports and ` summary.json ` go to ` .tmp/native-dupes-prototypes/ ` .
16- The prototype fixes the worker count at two. The table records this source revision, not a target
17- for later revisions. Percentages are jscpd's duplicated-line metric, not unique lines to remove.
18- Files below the token minimum do not contribute to its analyzed-file count.
26+ The version command must report ` jscpd 5.4.2 ` . The commands below fix the worker count at two.
27+ ` --no-gitignore ` lets the tracked-source archive be scanned independently of its temporary path;
28+ the archive contains no ignored build output. Each row has a native scan and a separate scan of
29+ the two TypeScript tests. Reports go to ` .tmp/native-dupes-prototypes/ ` .
1930
2031| Mode | Tokens / lines | Native clones | Duplicated lines | Duplication | Duo pair clones | Duo panel fragments |
2132| --- | --- | ---: | ---: | ---: | ---: | ---: |
@@ -28,6 +39,44 @@ Files below the token minimum do not contribute to its analyzed-file count.
2839| weak + consistent identifier normalization | 50 / 5 | 196 | 2150 | 4.44% | 5 | 0 |
2940| weak + gaps up to 8 lines | 30 / 3 | 384 | 2960 | 6.10% | 13 | 0 |
3041
42+ Exact commands, in table order:
43+
44+ ``` sh
45+ # mild-50-5
46+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode mild --min-tokens 50 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/mild-50-5-native
47+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode mild --min-tokens 50 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/mild-50-5-duo
48+
49+ # weak-50-5
50+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 50 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-50-5-native
51+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 50 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-50-5-duo
52+
53+ # weak-70-5
54+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 70 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-70-5-native
55+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 70 --min-lines 5 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-70-5-duo
56+
57+ # weak-100-8
58+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 100 --min-lines 8 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-100-8-native
59+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 100 --min-lines 8 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-100-8-duo
60+
61+ # weak-30-3
62+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 30 --min-lines 3 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-30-3-native
63+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 30 --min-lines 3 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-30-3-duo
64+
65+ # weak-20-3
66+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 20 --min-lines 3 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-20-3-native
67+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 20 --min-lines 3 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/weak-20-3-duo
68+
69+ # renamed-50-5
70+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 50 --min-lines 5 --ignore-identifiers=consistent --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/renamed-50-5-native
71+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 50 --min-lines 5 --ignore-identifiers=consistent --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/renamed-50-5-duo
72+
73+ # gap-30-3
74+ pnpm exec jscpd " $native_dupes_source /apple" " $native_dupes_source /android" " $native_dupes_source /linux" --format swift,objectivec,kotlin,java,python --formats-exts objectivec:m,h --mode weak --min-tokens 30 --min-lines 3 --max-gap-lines 8 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/gap-30-3-native
75+ pnpm exec jscpd " $native_dupes_source /packages/platform-apple/src/core/__tests__/display-inventory.test.ts" " $native_dupes_source /packages/platform-apple/src/__tests__/simctl-facade.test.ts" --format typescript --mode weak --min-tokens 30 --min-lines 3 --max-gap-lines 8 --workers 2 --no-gitignore --absolute --reporters json --output .tmp/native-dupes-prototypes/gap-30-3-duo
76+
77+ rm -rf " $native_dupes_source "
78+ ```
79+
3180The measured native runs took about 170–195 ms each, including Node startup, using two workers.
3281This is a single timing sample per variant, not a performance benchmark. Linux execution belongs
3382to the Repo Guards & Compatibility CI job.
@@ -53,16 +102,23 @@ in 5.1.0. A custom comparison script or percentage ceiling is unnecessary. The b
53102content fingerprints and clone multiplicities. It tolerates line shifts and fails on a third copy
54103of an accepted pair. A new clone fails even if another clone is removed and the total stays equal.
55104The executable policy tests cover each language, headers, line shifts, extra copies, replacement
56- clones, missing baselines, and empty scans.
105+ clones, missing baselines, empty scans, and removed-clone pruning .
57106
58107The rollout starts with a report-only measurement and saves that result in
59108` native-dupes-baseline.json ` . ` check:native-dupes ` then rejects new fingerprints or increased
60109multiplicities. It scans all native files rather than filtering by changed files. This keeps
61110unchanged files available as comparison targets and needs no Git history in CI. ` check:affected `
62- selects it for native source changes; configuration and baseline changes select the full check set.
111+ selects it for non-documentation changes under the roots in ` .jscpd-native.json ` . It does not
112+ filter by extension, so new scanner formats cannot escape selection. Some metadata changes also
113+ select this inexpensive scan. Configuration and baseline changes select the full check set.
63114` --changed ` is unsuitable for PR enforcement because it filters by working-tree status, which is
64115empty after a commit. The normal check never updates the baseline.
65116
117+ After rebasing onto ` 21f3f50a90f21bf8f994e742cbb7dd295f255d6c ` , the initial baseline was
118+ refreshed from main's native source: 82 clones, 854 duplicated lines (1.78%), and 218 analyzed
119+ files. Three fingerprints were replaced by upstream native changes. The table above remains the
120+ historical comparison at ` a16d4372376bf18eea3dff4cbe85e15fc68e7fc0 ` .
121+
66122## Motivating cases and limits
67123
68124The closed-Duo fixtures differ at the measured revision. ` display-inventory.test.ts ` includes
@@ -91,3 +147,11 @@ share an owner. If retaining duplication is intentional, review its source befor
91147` pnpm native-dupes:baseline ` . Review the baseline diff together with the source change. Do not
92148regenerate it merely to clear a failing check. A detector upgrade or a change to matching options
93149also needs a fresh comparison and baseline review. Missing baselines and empty scans fail closed.
150+
151+ The normal check does not prune stale fingerprints. If a clone disappears while its fingerprint
152+ remains in the baseline, the same block can be reintroduced up to its saved multiplicity without
153+ failing. When removing a clone, run ` pnpm native-dupes:baseline ` in the same PR. jscpd's
154+ ` --update-baseline ` replaces the saved fingerprints with those found by that scan, removing absent
155+ fingerprints and reducing obsolete multiplicities. Review that the refresh removes or reduces
156+ entries; investigate any additions. The executable pruning test proves that removal passes,
157+ an unpruned allowance accepts reintroduction, and a refreshed baseline rejects reintroduction.
0 commit comments