[{"data":1,"prerenderedAt":4686},["ShallowReactive",2],{"navigation_docs":3,"blog-posts":249,"blog-views":4676},[4,29,104,124,194],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":-1},"Start",false,"\u002Fstart","1.start",[10,14,19,24],{"title":11,"path":7,"stem":12,"icon":13},"What jscpd finds","1.start\u002Findex","i-lucide-house",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fstart\u002Finstallation","1.start\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Quickstart","\u002Fstart\u002Fquickstart","1.start\u002F3.quickstart","i-lucide-rocket",{"title":25,"path":26,"stem":27,"icon":28},"Configuration basics","\u002Fstart\u002Fconfiguration","1.start\u002F4.configuration","i-lucide-settings-2",{"title":30,"icon":6,"path":31,"stem":32,"children":33,"page":6},"Guides","\u002Fguides","2.guides",[34,39,44,49,54,59,64,69,74,79,84,89,94,99],{"title":35,"path":36,"stem":37,"icon":38},"Use jscpd in CI","\u002Fguides\u002Fci","2.guides\u002F01.ci","i-lucide-github",{"title":40,"path":41,"stem":42,"icon":43},"Pre-commit hooks","\u002Fguides\u002Fpre-commit","2.guides\u002F02.pre-commit","i-lucide-git-commit",{"title":45,"path":46,"stem":47,"icon":48},"Fail only on new duplication","\u002Fguides\u002Fbaseline","2.guides\u002F03.baseline","i-lucide-git-compare",{"title":50,"path":51,"stem":52,"icon":53},"Monorepos","\u002Fguides\u002Fmonorepos","2.guides\u002F04.monorepos","i-lucide-folder-tree",{"title":55,"path":56,"stem":57,"icon":58},"Cross-format detection","\u002Fguides\u002Fcross-format","2.guides\u002F05.cross-format","i-lucide-layers",{"title":60,"path":61,"stem":62,"icon":63},"Agents","\u002Fguides\u002Fagents","2.guides\u002F06.agents","i-lucide-cpu",{"title":65,"path":66,"stem":67,"icon":68},"Editors","\u002Fguides\u002Feditors","2.guides\u002F07.editors","i-lucide-code",{"title":70,"path":71,"stem":72,"icon":73},"Duplication over git history","\u002Fguides\u002Fhistory","2.guides\u002F08.history","i-lucide-chart-no-axes-combined",{"title":75,"path":76,"stem":77,"icon":78},"Dashboard and health score","\u002Fguides\u002Fdashboard","2.guides\u002F09.dashboard","i-lucide-layout-dashboard",{"title":80,"path":81,"stem":82,"icon":83},"Dead code","\u002Fguides\u002Fdead-code","2.guides\u002F10.dead-code","i-lucide-ghost",{"title":85,"path":86,"stem":87,"icon":88},"Comparing two codebases","\u002Fguides\u002Fcompare","2.guides\u002F11.compare","i-lucide-git-compare-arrows",{"title":90,"path":91,"stem":92,"icon":93},"Semantic clones","\u002Fguides\u002Fsemantic-clones","2.guides\u002F12.semantic-clones","i-lucide-brain-circuit",{"title":95,"path":96,"stem":97,"icon":98},"Similar functions","\u002Fguides\u002Fsimilarity","2.guides\u002F13.similarity","i-lucide-list-tree",{"title":100,"path":101,"stem":102,"icon":103},"Boundaries","\u002Fguides\u002Fboundaries","2.guides\u002F14.boundaries","i-lucide-fence",{"title":105,"icon":6,"path":106,"stem":107,"children":108,"page":6},"Concepts","\u002Fconcepts","3.concepts",[109,114,119],{"title":110,"path":111,"stem":112,"icon":113},"Types of code clones","\u002Fconcepts\u002Fclone-types","3.concepts\u002F1.clone-types","i-lucide-copy",{"title":115,"path":116,"stem":117,"icon":118},"How detection works","\u002Fconcepts\u002Fhow-detection-works","3.concepts\u002F2.how-detection-works","i-lucide-scan-search",{"title":120,"path":121,"stem":122,"icon":123},"The health score","\u002Fconcepts\u002Fhealth-score","3.concepts\u002F3.health-score","i-lucide-heart-pulse",{"title":125,"icon":6,"path":126,"stem":127,"children":128,"page":6},"Reference","\u002Freference","4.reference",[129,134,139,144,181,186,190],{"title":130,"path":131,"stem":132,"icon":133},"CLI options","\u002Freference\u002Fcli","4.reference\u002F1.cli","i-lucide-terminal",{"title":135,"path":136,"stem":137,"icon":138},"The config file","\u002Freference\u002Fconfig-file","4.reference\u002F2.config-file","i-lucide-settings",{"title":140,"path":141,"stem":142,"icon":143},"Exit codes","\u002Freference\u002Fexit-codes","4.reference\u002F3.exit-codes","i-lucide-log-out",{"title":145,"icon":6,"path":146,"stem":147,"children":148,"page":-1},"Reporters","\u002Freference\u002Freporters","4.reference\u002F4.reporters\u002Findex",[149,151,156,161,166,171,176],{"title":145,"path":146,"stem":147,"icon":150},"i-lucide-file-chart-column",{"title":152,"path":153,"stem":154,"icon":155},"HTML reporter","\u002Freference\u002Freporters\u002Fhtml","4.reference\u002F4.reporters\u002F2.html","i-lucide-file-code",{"title":157,"path":158,"stem":159,"icon":160},"JSON reporter","\u002Freference\u002Freporters\u002Fjson","4.reference\u002F4.reporters\u002F3.json","i-lucide-braces",{"title":162,"path":163,"stem":164,"icon":165},"Badge reporter","\u002Freference\u002Freporters\u002Fbadge","4.reference\u002F4.reporters\u002F4.badge","i-lucide-award",{"title":167,"path":168,"stem":169,"icon":170},"SARIF reporter","\u002Freference\u002Freporters\u002Fsarif","4.reference\u002F4.reporters\u002F5.sarif","i-lucide-shield-check",{"title":172,"path":173,"stem":174,"icon":175},"CodeClimate reporter","\u002Freference\u002Freporters\u002Fcodeclimate","4.reference\u002F4.reporters\u002F6.codeclimate","i-lucide-flag-triangle-right",{"title":177,"path":178,"stem":179,"icon":180},"OpenMetrics reporter","\u002Freference\u002Freporters\u002Fopenmetrics","4.reference\u002F4.reporters\u002F7.openmetrics","i-lucide-activity",{"title":182,"path":183,"stem":184,"icon":185},"Supported formats","\u002Freference\u002Fsupported-formats","4.reference\u002F5.supported-formats","i-lucide-languages",{"title":187,"path":188,"stem":189,"icon":38},"GitHub Action","\u002Freference\u002Fgithub-action","4.reference\u002F6.github-action",{"title":191,"path":192,"stem":193,"icon":68},"Rust crates","\u002Freference\u002Frust-crates","4.reference\u002F7.rust-crates",{"title":195,"icon":6,"path":196,"stem":197,"children":198,"page":6},"Project","\u002Fproject","5.project",[199,204,209,214,239,244],{"title":200,"path":201,"stem":202,"icon":203},"Changelog","\u002Fproject\u002Fchangelog","5.project\u002F1.changelog","i-lucide-scroll-text",{"title":205,"path":206,"stem":207,"icon":208},"Migrating from v4 to v5","\u002Fproject\u002Fmigration","5.project\u002F2.migration","i-lucide-arrow-right-left",{"title":210,"path":211,"stem":212,"icon":213},"jscpd v4 (TypeScript)","\u002Fproject\u002Fv4","5.project\u002F3.v4","i-simple-icons-typescript",{"title":215,"icon":6,"path":216,"stem":217,"children":218,"page":-1},"Benchmarks","\u002Fproject\u002Fbenchmarks","5.project\u002F4.benchmarks\u002Findex",[219,221,226,230,235],{"title":215,"path":216,"stem":217,"icon":220},"i-lucide-gauge",{"title":222,"path":223,"stem":224,"icon":225},"Detection Speed","\u002Fproject\u002Fbenchmarks\u002Fdetection-speed","5.project\u002F4.benchmarks\u002F2.detection-speed","i-lucide-zap",{"title":227,"path":228,"stem":229,"icon":58},"Multi-Format Detection","\u002Fproject\u002Fbenchmarks\u002Fcross-format","5.project\u002F4.benchmarks\u002F3.cross-format",{"title":231,"path":232,"stem":233,"icon":234},"AI Token Efficiency","\u002Fproject\u002Fbenchmarks\u002Fai-token-efficiency","5.project\u002F4.benchmarks\u002F4.ai-token-efficiency","i-lucide-sparkles",{"title":236,"path":237,"stem":238,"icon":93},"Embedding Models","\u002Fproject\u002Fbenchmarks\u002Fembedding-models","5.project\u002F4.benchmarks\u002F5.embedding-models",{"title":240,"path":241,"stem":242,"icon":243},"Research","\u002Fproject\u002Fresearch","5.project\u002F5.research","i-lucide-graduation-cap",{"title":245,"path":246,"stem":247,"icon":248},"Articles","\u002Fproject\u002Farticles","5.project\u002F6.articles","i-lucide-newspaper",[250,1810,3147,4084],{"id":251,"title":252,"authors":253,"body":255,"date":1798,"description":1799,"extension":1800,"meta":1801,"navigation":6,"path":1802,"publishedAt":1803,"seo":1804,"stem":1806,"tags":1807,"__hash__":1809},"blog\u002Fblog\u002Fjscpd-5-4-3.md","What's new in jscpd 5.4.3",[254],"kucherenko",{"type":256,"value":257,"toc":1787},"minimark",[258,262,267,295,574,599,636,640,643,666,685,689,700,737,783,791,794,1041,1044,1088,1130,1134,1141,1178,1199,1203,1210,1401,1515,1518,1563,1570,1656,1662,1666,1706,1710,1751,1783],[259,260,261],"p",{},"5.4.3 is a smaller release than 5.4.2. It adds a function for Node.js scripts, shows both sides of a clone in the HTML report, and fixes things people ran into in real projects: an Action that ignored the pinned version, ignore regions that leaked, and dead-code findings that weren't dead. Most of the fixes came from issues with a reproduction and the cause, and several came with the fix too.",[263,264,266],"h2",{"id":265},"run-jscpd-from-a-nodejs-script","Run jscpd from a Node.js script",[259,268,269,270,274,275,278,279,282,283,286,287,290,291,294],{},"The npm package used to give you only the ",[271,272,273],"code",{},"jscpd"," command. A script that wanted to run it started a second Node.js process with ",[271,276,277],{},"npx jscpd",", and tools such as knip didn't see that the project uses jscpd. Now ",[271,280,281],{},"require(\"jscpd\")"," and ",[271,284,285],{},"import { runJscpd } from \"jscpd\""," give you ",[271,288,289],{},"runJscpd(args, options)",". It finds the binary for the platform the same way the command does and returns what ",[271,292,293],{},"spawnSync"," returns:",[296,297,302],"pre",{"className":298,"code":299,"language":300,"meta":301,"style":301},"language-js shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { runJscpd } from \"jscpd\";\n\nconst { status, stderr } = runJscpd(\n  [process.argv[2], \"--min-tokens\", \"25\", \"--threshold\", \"10\", \"--silent\"],\n  { encoding: \"utf8\" }\n);\nif (status !== 0) {\n  console.error(stderr.trim());\n  process.exit(status);\n}\nconsole.log(\"duplication is under 10%\");\n","js","",[271,303,304,339,346,376,445,468,476,497,524,544,550],{"__ignoreMap":301},[305,306,309,313,317,321,324,327,330,333,336],"span",{"class":307,"line":308},"line",1,[305,310,312],{"class":311},"s7zQu","import",[305,314,316],{"class":315},"sMK4o"," {",[305,318,320],{"class":319},"sTEyZ"," runJscpd",[305,322,323],{"class":315}," }",[305,325,326],{"class":311}," from",[305,328,329],{"class":315}," \"",[305,331,273],{"class":332},"sfazB",[305,334,335],{"class":315},"\"",[305,337,338],{"class":315},";\n",[305,340,342],{"class":307,"line":341},2,[305,343,345],{"emptyLinePlaceholder":344},true,"\n",[305,347,349,353,355,358,361,364,367,370,373],{"class":307,"line":348},3,[305,350,352],{"class":351},"spNyl","const",[305,354,316],{"class":315},[305,356,357],{"class":319}," status",[305,359,360],{"class":315},",",[305,362,363],{"class":319}," stderr ",[305,365,366],{"class":315},"}",[305,368,369],{"class":315}," =",[305,371,320],{"class":372},"s2Zo4",[305,374,375],{"class":319},"(\n",[305,377,379,382,385,388,392,395,397,399,402,404,406,408,411,413,415,417,420,422,424,426,429,431,433,435,438,440,442],{"class":307,"line":378},4,[305,380,381],{"class":319},"  [process",[305,383,384],{"class":315},".",[305,386,387],{"class":319},"argv[",[305,389,391],{"class":390},"sbssI","2",[305,393,394],{"class":319},"]",[305,396,360],{"class":315},[305,398,329],{"class":315},[305,400,401],{"class":332},"--min-tokens",[305,403,335],{"class":315},[305,405,360],{"class":315},[305,407,329],{"class":315},[305,409,410],{"class":332},"25",[305,412,335],{"class":315},[305,414,360],{"class":315},[305,416,329],{"class":315},[305,418,419],{"class":332},"--threshold",[305,421,335],{"class":315},[305,423,360],{"class":315},[305,425,329],{"class":315},[305,427,428],{"class":332},"10",[305,430,335],{"class":315},[305,432,360],{"class":315},[305,434,329],{"class":315},[305,436,437],{"class":332},"--silent",[305,439,335],{"class":315},[305,441,394],{"class":319},[305,443,444],{"class":315},",\n",[305,446,448,451,455,458,460,463,465],{"class":307,"line":447},5,[305,449,450],{"class":315},"  {",[305,452,454],{"class":453},"swJcz"," encoding",[305,456,457],{"class":315},":",[305,459,329],{"class":315},[305,461,462],{"class":332},"utf8",[305,464,335],{"class":315},[305,466,467],{"class":315}," }\n",[305,469,471,474],{"class":307,"line":470},6,[305,472,473],{"class":319},")",[305,475,338],{"class":315},[305,477,479,482,485,488,491,494],{"class":307,"line":478},7,[305,480,481],{"class":311},"if",[305,483,484],{"class":319}," (status ",[305,486,487],{"class":315},"!==",[305,489,490],{"class":390}," 0",[305,492,493],{"class":319},") ",[305,495,496],{"class":315},"{\n",[305,498,500,503,505,508,511,514,516,519,522],{"class":307,"line":499},8,[305,501,502],{"class":319},"  console",[305,504,384],{"class":315},[305,506,507],{"class":372},"error",[305,509,510],{"class":453},"(",[305,512,513],{"class":319},"stderr",[305,515,384],{"class":315},[305,517,518],{"class":372},"trim",[305,520,521],{"class":453},"())",[305,523,338],{"class":315},[305,525,527,530,532,535,537,540,542],{"class":307,"line":526},9,[305,528,529],{"class":319},"  process",[305,531,384],{"class":315},[305,533,534],{"class":372},"exit",[305,536,510],{"class":453},[305,538,539],{"class":319},"status",[305,541,473],{"class":453},[305,543,338],{"class":315},[305,545,547],{"class":307,"line":546},10,[305,548,549],{"class":315},"}\n",[305,551,553,556,558,561,563,565,568,570,572],{"class":307,"line":552},11,[305,554,555],{"class":319},"console",[305,557,384],{"class":315},[305,559,560],{"class":372},"log",[305,562,510],{"class":319},[305,564,335],{"class":315},[305,566,567],{"class":332},"duplication is under 10%",[305,569,335],{"class":315},[305,571,473],{"class":319},[305,573,338],{"class":315},[296,575,579],{"className":576,"code":577,"language":578,"meta":301,"style":301},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","node check.mjs src\n# ERROR: jscpd found too many duplicates (50.0%) over threshold (10.0%)\n","bash",[271,580,581,593],{"__ignoreMap":301},[305,582,583,587,590],{"class":307,"line":308},[305,584,586],{"class":585},"sBMFI","node",[305,588,589],{"class":332}," check.mjs",[305,591,592],{"class":332}," src\n",[305,594,595],{"class":307,"line":341},[305,596,598],{"class":597},"sHwdD","# ERROR: jscpd found too many duplicates (50.0%) over threshold (10.0%)\n",[259,600,601,602,605,606,609,610,613,614,617,618,625,626,631,632,635],{},"Where the command prints an error and exits, for example on a platform without a prebuilt binary, the function throws an ",[271,603,604],{},"Error"," with the same message and ",[271,607,608],{},"code === \"JSCPD_NO_BINARY\"",". The types are in ",[271,611,612],{},"index.d.ts",". Detection still runs in the Rust binary only, so this is a way to start it, not the v4 ",[271,615,616],{},"jscpd()"," API. ",[619,620,624],"a",{"href":621,"rel":622},"https:\u002F\u002Fgithub.com\u002Fabrahamguo",[623],"nofollow","@abrahamguo"," wrote it (",[619,627,630],{"href":628,"rel":629},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1238",[623],"#1238","), and the next release adds ",[271,633,634],{},"getJscpdReport()"," from the same author, which returns the parsed JSON report.",[263,637,639],{"id":638},"both-sides-of-a-clone-in-the-html-report","Both sides of a clone in the HTML report",[259,641,642],{},"\"Show code\" in the HTML report opened only the first fragment, so to see what it was a copy of you went to the other file yourself. Now it opens both fragments side by side, or one above the other on a narrow screen. Each fragment sits under its file name with line numbers, and a long line scrolls inside its own pane. The report highlights the code with Prism again, as the v4 report did, and inlines only the languages it shows, so the file stays small: the report below is 27 KB.",[296,644,646],{"className":576,"code":645,"language":578,"meta":301,"style":301},"jscpd --reporters html fixtures\u002Ffile-names-demo\n# HTML report saved to report\u002Fjscpd-report.html\n",[271,647,648,661],{"__ignoreMap":301},[305,649,650,652,655,658],{"class":307,"line":308},[305,651,273],{"class":585},[305,653,654],{"class":332}," --reporters",[305,656,657],{"class":332}," html",[305,659,660],{"class":332}," fixtures\u002Ffile-names-demo\n",[305,662,663],{"class":307,"line":341},[305,664,665],{"class":597},"# HTML report saved to report\u002Fjscpd-report.html\n",[259,667,668,673,674,679,680,384],{},[619,669,672],{"href":670,"target":671},"\u002Fexamples\u002Fhtml-report-demo.html","_blank","Open the report"," of the file names demo: three clones, in Elixir, in a Dockerfile and in a Makefile. Thanks to ",[619,675,678],{"href":676,"rel":677},"https:\u002F\u002Fgithub.com\u002Fcrystalfp",[623],"@crystalfp"," for ",[619,681,684],{"href":682,"rel":683},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1263",[623],"the issue",[263,686,688],{"id":687},"pinning-the-action-pins-jscpd","Pinning the Action pins jscpd",[259,690,691,692,695,696,699],{},"The ",[271,693,694],{},"version"," input of the GitHub Action defaulted to ",[271,697,698],{},"latest",". So this workflow installed jscpd 5.4.2 the day 5.4.2 came out, even though it pins the Action to 5.4.1:",[296,701,705],{"className":702,"code":703,"language":704,"meta":301,"style":301},"language-yaml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","- uses: kucherenko\u002Fjscpd@v5.4.1\n  with:\n    path: src\n","yaml",[271,706,707,720,728],{"__ignoreMap":301},[305,708,709,712,715,717],{"class":307,"line":308},[305,710,711],{"class":315},"-",[305,713,714],{"class":453}," uses",[305,716,457],{"class":315},[305,718,719],{"class":332}," kucherenko\u002Fjscpd@v5.4.1\n",[305,721,722,725],{"class":307,"line":341},[305,723,724],{"class":453},"  with",[305,726,727],{"class":315},":\n",[305,729,730,733,735],{"class":307,"line":348},[305,731,732],{"class":453},"    path",[305,734,457],{"class":315},[305,736,592],{"class":332},[259,738,739,740,742,743,746,747,750,751,754,755,758,759,764,765,770,771,776,777,782],{},"From v5.4.3 on, an empty ",[271,741,694],{}," installs the release that the Action's own ref belongs to. Pin ",[271,744,745],{},"kucherenko\u002Fjscpd@v5.4.3"," or its commit SHA, and you get jscpd 5.4.3 until you move the pin, and a Dependabot bump of the Action updates both. ",[271,748,749],{},"version: latest"," still installs the newest release, and ",[271,752,753],{},"@v5"," keeps following the latest 5.x as before. Older tags can't learn this, so ",[271,756,757],{},"@v5.4.1"," still installs the newest jscpd. Reported by ",[619,760,763],{"href":761,"rel":762},"https:\u002F\u002Fgithub.com\u002Fdannystaple",[623],"@dannystaple",", fixed by ",[619,766,769],{"href":767,"rel":768},"https:\u002F\u002Fgithub.com\u002Fsarankumar1325",[623],"@sarankumar1325"," (",[619,772,775],{"href":773,"rel":774},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1240",[623],"#1240",", ",[619,778,781],{"href":779,"rel":780},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1249",[623],"#1249",").",[263,784,786,787,790],{"id":785},"jscpdignore-regions-with-in-a-string","jscpd:ignore regions with ",[271,788,789],{},"\u002F*"," in a string",[259,792,793],{},"Here is a list of routes between ignore markers, and a test fixture with the same list:",[296,795,799],{"className":796,"code":797,"language":798,"meta":301,"style":301},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F* jscpd:ignore-start *\u002F\nexport const PROTECTED_ROUTES = [\n  { path: \"\u002Fapi\u002Fauth\u002Forganization\u002F*\", roles: [\"owner\", \"admin\"], audit: true },\n  { path: \"\u002Fapi\u002Fauth\u002Fmembers\u002F*\", roles: [\"owner\", \"admin\"], audit: true },\n  { path: \"\u002Fapi\u002Fbilling\u002Finvoices\u002F*\", roles: [\"owner\", \"billing\"], audit: true },\n  { path: \"\u002Fapi\u002Fbilling\u002Fcards\u002F*\", roles: [\"owner\", \"billing\"], audit: false },\n];\n\u002F* jscpd:ignore-end *\u002F\n","ts",[271,800,801,806,823,881,930,980,1030,1036],{"__ignoreMap":301},[305,802,803],{"class":307,"line":308},[305,804,805],{"class":597},"\u002F* jscpd:ignore-start *\u002F\n",[305,807,808,811,814,817,820],{"class":307,"line":341},[305,809,810],{"class":311},"export",[305,812,813],{"class":351}," const",[305,815,816],{"class":319}," PROTECTED_ROUTES ",[305,818,819],{"class":315},"=",[305,821,822],{"class":319}," [\n",[305,824,825,827,830,832,834,837,839,841,844,846,849,851,854,856,858,860,863,865,867,869,872,874,878],{"class":307,"line":348},[305,826,450],{"class":315},[305,828,829],{"class":453}," path",[305,831,457],{"class":315},[305,833,329],{"class":315},[305,835,836],{"class":332},"\u002Fapi\u002Fauth\u002Forganization\u002F*",[305,838,335],{"class":315},[305,840,360],{"class":315},[305,842,843],{"class":453}," roles",[305,845,457],{"class":315},[305,847,848],{"class":319}," [",[305,850,335],{"class":315},[305,852,853],{"class":332},"owner",[305,855,335],{"class":315},[305,857,360],{"class":315},[305,859,329],{"class":315},[305,861,862],{"class":332},"admin",[305,864,335],{"class":315},[305,866,394],{"class":319},[305,868,360],{"class":315},[305,870,871],{"class":453}," audit",[305,873,457],{"class":315},[305,875,877],{"class":876},"sfNiH"," true",[305,879,880],{"class":315}," },\n",[305,882,883,885,887,889,891,894,896,898,900,902,904,906,908,910,912,914,916,918,920,922,924,926,928],{"class":307,"line":378},[305,884,450],{"class":315},[305,886,829],{"class":453},[305,888,457],{"class":315},[305,890,329],{"class":315},[305,892,893],{"class":332},"\u002Fapi\u002Fauth\u002Fmembers\u002F*",[305,895,335],{"class":315},[305,897,360],{"class":315},[305,899,843],{"class":453},[305,901,457],{"class":315},[305,903,848],{"class":319},[305,905,335],{"class":315},[305,907,853],{"class":332},[305,909,335],{"class":315},[305,911,360],{"class":315},[305,913,329],{"class":315},[305,915,862],{"class":332},[305,917,335],{"class":315},[305,919,394],{"class":319},[305,921,360],{"class":315},[305,923,871],{"class":453},[305,925,457],{"class":315},[305,927,877],{"class":876},[305,929,880],{"class":315},[305,931,932,934,936,938,940,943,945,947,949,951,953,955,957,959,961,963,966,968,970,972,974,976,978],{"class":307,"line":447},[305,933,450],{"class":315},[305,935,829],{"class":453},[305,937,457],{"class":315},[305,939,329],{"class":315},[305,941,942],{"class":332},"\u002Fapi\u002Fbilling\u002Finvoices\u002F*",[305,944,335],{"class":315},[305,946,360],{"class":315},[305,948,843],{"class":453},[305,950,457],{"class":315},[305,952,848],{"class":319},[305,954,335],{"class":315},[305,956,853],{"class":332},[305,958,335],{"class":315},[305,960,360],{"class":315},[305,962,329],{"class":315},[305,964,965],{"class":332},"billing",[305,967,335],{"class":315},[305,969,394],{"class":319},[305,971,360],{"class":315},[305,973,871],{"class":453},[305,975,457],{"class":315},[305,977,877],{"class":876},[305,979,880],{"class":315},[305,981,982,984,986,988,990,993,995,997,999,1001,1003,1005,1007,1009,1011,1013,1015,1017,1019,1021,1023,1025,1028],{"class":307,"line":470},[305,983,450],{"class":315},[305,985,829],{"class":453},[305,987,457],{"class":315},[305,989,329],{"class":315},[305,991,992],{"class":332},"\u002Fapi\u002Fbilling\u002Fcards\u002F*",[305,994,335],{"class":315},[305,996,360],{"class":315},[305,998,843],{"class":453},[305,1000,457],{"class":315},[305,1002,848],{"class":319},[305,1004,335],{"class":315},[305,1006,853],{"class":332},[305,1008,335],{"class":315},[305,1010,360],{"class":315},[305,1012,329],{"class":315},[305,1014,965],{"class":332},[305,1016,335],{"class":315},[305,1018,394],{"class":319},[305,1020,360],{"class":315},[305,1022,871],{"class":453},[305,1024,457],{"class":315},[305,1026,1027],{"class":876}," false",[305,1029,880],{"class":315},[305,1031,1032,1034],{"class":307,"line":478},[305,1033,394],{"class":319},[305,1035,338],{"class":315},[305,1037,1038],{"class":307,"line":499},[305,1039,1040],{"class":597},"\u002F* jscpd:ignore-end *\u002F\n",[259,1042,1043],{},"jscpd 5.4.2 reported the region anyway:",[296,1045,1047],{"className":576,"code":1046,"language":578,"meta":301,"style":301},"jscpd --min-tokens 25 --min-lines 3 .\n# Clone found (typescript)\n#  - src\u002Fauth\u002Froutes.ts [3:37 - 7:3] (5 lines, 70 tokens)\n#    test\u002Froutes.fixture.ts [2:37 - 6:3]\n# Found 1 clones.\n",[271,1048,1049,1068,1073,1078,1083],{"__ignoreMap":301},[305,1050,1051,1053,1056,1059,1062,1065],{"class":307,"line":308},[305,1052,273],{"class":585},[305,1054,1055],{"class":332}," --min-tokens",[305,1057,1058],{"class":390}," 25",[305,1060,1061],{"class":332}," --min-lines",[305,1063,1064],{"class":390}," 3",[305,1066,1067],{"class":332}," .\n",[305,1069,1070],{"class":307,"line":341},[305,1071,1072],{"class":597},"# Clone found (typescript)\n",[305,1074,1075],{"class":307,"line":348},[305,1076,1077],{"class":597},"#  - src\u002Fauth\u002Froutes.ts [3:37 - 7:3] (5 lines, 70 tokens)\n",[305,1079,1080],{"class":307,"line":378},[305,1081,1082],{"class":597},"#    test\u002Froutes.fixture.ts [2:37 - 6:3]\n",[305,1084,1085],{"class":307,"line":447},[305,1086,1087],{"class":597},"# Found 1 clones.\n",[259,1089,1090,1091,1093,1094,1097,1098,1101,1102,1105,1106,1109,1110,1115,1116,1119,1120,776,1125,782],{},"The JavaScript and TypeScript tokenizer looked for the markers with a byte scan that took every ",[271,1092,789],{}," for the start of a comment, the one in ",[271,1095,1096],{},"\"\u002Fapi\u002Fauth\u002Forganization\u002F*\""," too. That fake comment ran to the next ",[271,1099,1100],{},"*\u002F",", the one that closes ",[271,1103,1104],{},"jscpd:ignore-end",", so the region ended at the first route. 5.4.3 finds the markers by their text, as the other languages do, and prints ",[271,1107,1108],{},"Found 0 clones."," Markers inside template literals, such as the CSS of a styled component, work as before. ",[619,1111,1114],{"href":1112,"rel":1113},"https:\u002F\u002Fgithub.com\u002Fbauchdj",[623],"@bauchdj"," found it in a data file of URL globs that gave 126 clones, and sent the cause; ",[619,1117,769],{"href":767,"rel":1118},[623]," fixed it (",[619,1121,1124],{"href":1122,"rel":1123},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1257",[623],"#1257",[619,1126,1129],{"href":1127,"rel":1128},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1258",[623],"#1258",[263,1131,1133],{"id":1132},"ignore-this-clone-in-jsx","\"Ignore this clone\" in JSX",[259,1135,1136,1137,1140],{},"The language server's \"Ignore this clone\" action wrote ",[271,1138,1139],{},"\u002F\u002F jscpd:ignore-start"," among JSX children, where the page renders it as text, and it could put a marker inside a tag, which TypeScript can't parse. Now it writes markers that JSX accepts and keeps them outside of tags:",[296,1142,1146],{"className":1143,"code":1144,"language":1145,"meta":301,"style":301},"language-tsx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cul>\n  {\u002F* jscpd:ignore-start *\u002F}\n  \u003Cli>{order.id}\u003C\u002Fli>\n  \u003Cli>{order.total}\u003C\u002Fli>\n  {\u002F* jscpd:ignore-end *\u002F}\n\u003C\u002Ful>\n","tsx",[271,1147,1148,1153,1158,1163,1168,1173],{"__ignoreMap":301},[305,1149,1150],{"class":307,"line":308},[305,1151,1152],{},"\u003Cul>\n",[305,1154,1155],{"class":307,"line":341},[305,1156,1157],{},"  {\u002F* jscpd:ignore-start *\u002F}\n",[305,1159,1160],{"class":307,"line":348},[305,1161,1162],{},"  \u003Cli>{order.id}\u003C\u002Fli>\n",[305,1164,1165],{"class":307,"line":378},[305,1166,1167],{},"  \u003Cli>{order.total}\u003C\u002Fli>\n",[305,1169,1170],{"class":307,"line":447},[305,1171,1172],{},"  {\u002F* jscpd:ignore-end *\u002F}\n",[305,1174,1175],{"class":307,"line":470},[305,1176,1177],{},"\u003C\u002Ful>\n",[259,1179,1180,1181,1184,1185,1188,1189,776,1194,782],{},"When the clone starts or ends inside a tag, the start marker goes before the tag and the end marker after it. Each copy of a ",[271,1182,1183],{},"--cross-formats"," clone gets the comment syntax of its own file, and the ",[271,1186,1187],{},"\u003Cscript lang=\"tsx\">"," of a Vue, Svelte or Astro component gets the JSX markers (",[619,1190,1193],{"href":1191,"rel":1192},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1260",[623],"#1260",[619,1195,1198],{"href":1196,"rel":1197},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1264",[623],"#1264",[263,1200,1202],{"id":1201},"dead-code-that-wasnt-dead","Dead code that wasn't dead",[259,1204,1205,1206,1209],{},"Three reports from ",[619,1207,624],{"href":621,"rel":1208},[623]," came with the cause, and in this small project two of them show up at once:",[296,1211,1213],{"className":298,"code":1212,"language":300,"meta":301,"style":301},"\u002F\u002F src\u002Fmain.js\nimport { Cart } from \".\u002Fcart.js\";\n\nconst cart = new Cart(\"EUR\");\ncart.add({ sku: \"tea\", price: 450 });\n\nexport async function openAdmin() {\n  const { renderAdmin } = await import(`.\u002Fadmin\u002Fpanel.js`);\n  renderAdmin(document.body, cart);\n}\n",[271,1214,1215,1220,1242,1246,1273,1316,1320,1339,1373,1397],{"__ignoreMap":301},[305,1216,1217],{"class":307,"line":308},[305,1218,1219],{"class":597},"\u002F\u002F src\u002Fmain.js\n",[305,1221,1222,1224,1226,1229,1231,1233,1235,1238,1240],{"class":307,"line":341},[305,1223,312],{"class":311},[305,1225,316],{"class":315},[305,1227,1228],{"class":319}," Cart",[305,1230,323],{"class":315},[305,1232,326],{"class":311},[305,1234,329],{"class":315},[305,1236,1237],{"class":332},".\u002Fcart.js",[305,1239,335],{"class":315},[305,1241,338],{"class":315},[305,1243,1244],{"class":307,"line":348},[305,1245,345],{"emptyLinePlaceholder":344},[305,1247,1248,1250,1253,1255,1258,1260,1262,1264,1267,1269,1271],{"class":307,"line":378},[305,1249,352],{"class":351},[305,1251,1252],{"class":319}," cart ",[305,1254,819],{"class":315},[305,1256,1257],{"class":315}," new",[305,1259,1228],{"class":372},[305,1261,510],{"class":319},[305,1263,335],{"class":315},[305,1265,1266],{"class":332},"EUR",[305,1268,335],{"class":315},[305,1270,473],{"class":319},[305,1272,338],{"class":315},[305,1274,1275,1278,1280,1283,1285,1288,1291,1293,1295,1298,1300,1302,1305,1307,1310,1312,1314],{"class":307,"line":447},[305,1276,1277],{"class":319},"cart",[305,1279,384],{"class":315},[305,1281,1282],{"class":372},"add",[305,1284,510],{"class":319},[305,1286,1287],{"class":315},"{",[305,1289,1290],{"class":453}," sku",[305,1292,457],{"class":315},[305,1294,329],{"class":315},[305,1296,1297],{"class":332},"tea",[305,1299,335],{"class":315},[305,1301,360],{"class":315},[305,1303,1304],{"class":453}," price",[305,1306,457],{"class":315},[305,1308,1309],{"class":390}," 450",[305,1311,323],{"class":315},[305,1313,473],{"class":319},[305,1315,338],{"class":315},[305,1317,1318],{"class":307,"line":470},[305,1319,345],{"emptyLinePlaceholder":344},[305,1321,1322,1324,1327,1330,1333,1336],{"class":307,"line":478},[305,1323,810],{"class":311},[305,1325,1326],{"class":351}," async",[305,1328,1329],{"class":351}," function",[305,1331,1332],{"class":372}," openAdmin",[305,1334,1335],{"class":315},"()",[305,1337,1338],{"class":315}," {\n",[305,1340,1341,1344,1346,1349,1351,1353,1356,1359,1361,1364,1367,1369,1371],{"class":307,"line":499},[305,1342,1343],{"class":351},"  const",[305,1345,316],{"class":315},[305,1347,1348],{"class":319}," renderAdmin",[305,1350,323],{"class":315},[305,1352,369],{"class":315},[305,1354,1355],{"class":311}," await",[305,1357,1358],{"class":315}," import",[305,1360,510],{"class":453},[305,1362,1363],{"class":315},"`",[305,1365,1366],{"class":332},".\u002Fadmin\u002Fpanel.js",[305,1368,1363],{"class":315},[305,1370,473],{"class":453},[305,1372,338],{"class":315},[305,1374,1375,1378,1380,1383,1385,1388,1390,1393,1395],{"class":307,"line":526},[305,1376,1377],{"class":372},"  renderAdmin",[305,1379,510],{"class":453},[305,1381,1382],{"class":319},"document",[305,1384,384],{"class":315},[305,1386,1387],{"class":319},"body",[305,1389,360],{"class":315},[305,1391,1392],{"class":319}," cart",[305,1394,473],{"class":453},[305,1396,338],{"class":315},[305,1398,1399],{"class":307,"line":546},[305,1400,549],{"class":315},[296,1402,1404],{"className":298,"code":1403,"language":300,"meta":301,"style":301},"\u002F\u002F src\u002Fcart.js\nexport class Cart {\n  constructor(currency) {\n    this.currency = currency;\n    this.items = [];\n  }\n\n  add(item) {\n    this.items.push(item);\n  }\n}\n",[271,1405,1406,1411,1422,1437,1451,1465,1470,1474,1488,1507,1511],{"__ignoreMap":301},[305,1407,1408],{"class":307,"line":308},[305,1409,1410],{"class":597},"\u002F\u002F src\u002Fcart.js\n",[305,1412,1413,1415,1418,1420],{"class":307,"line":341},[305,1414,810],{"class":311},[305,1416,1417],{"class":351}," class",[305,1419,1228],{"class":585},[305,1421,1338],{"class":315},[305,1423,1424,1427,1429,1433,1435],{"class":307,"line":348},[305,1425,1426],{"class":351},"  constructor",[305,1428,510],{"class":315},[305,1430,1432],{"class":1431},"sHdIc","currency",[305,1434,473],{"class":315},[305,1436,1338],{"class":315},[305,1438,1439,1442,1444,1446,1449],{"class":307,"line":378},[305,1440,1441],{"class":315},"    this.",[305,1443,1432],{"class":319},[305,1445,369],{"class":315},[305,1447,1448],{"class":319}," currency",[305,1450,338],{"class":315},[305,1452,1453,1455,1458,1460,1463],{"class":307,"line":447},[305,1454,1441],{"class":315},[305,1456,1457],{"class":319},"items",[305,1459,369],{"class":315},[305,1461,1462],{"class":453}," []",[305,1464,338],{"class":315},[305,1466,1467],{"class":307,"line":470},[305,1468,1469],{"class":315},"  }\n",[305,1471,1472],{"class":307,"line":478},[305,1473,345],{"emptyLinePlaceholder":344},[305,1475,1476,1479,1481,1484,1486],{"class":307,"line":499},[305,1477,1478],{"class":453},"  add",[305,1480,510],{"class":315},[305,1482,1483],{"class":1431},"item",[305,1485,473],{"class":315},[305,1487,1338],{"class":315},[305,1489,1490,1492,1494,1496,1499,1501,1503,1505],{"class":307,"line":526},[305,1491,1441],{"class":315},[305,1493,1457],{"class":319},[305,1495,384],{"class":315},[305,1497,1498],{"class":372},"push",[305,1500,510],{"class":453},[305,1502,1483],{"class":319},[305,1504,473],{"class":453},[305,1506,338],{"class":315},[305,1508,1509],{"class":307,"line":546},[305,1510,1469],{"class":315},[305,1512,1513],{"class":307,"line":552},[305,1514,549],{"class":315},[259,1516,1517],{},"jscpd 5.4.2:",[296,1519,1521],{"className":576,"code":1520,"language":578,"meta":301,"style":301},"jscpd --dead-code --dead-code-categories all .\n# Unused files (1)\n#  - src\u002Fadmin\u002Fpanel.js  certain 95%  3 lines\n# Unused members (1)\n#  - method src\u002Fcart.js:2:3 Cart.constructor  medium 70%  4 lines\n# Found 2 dead code findings in 3 files (31.8% of 22 lines).\n",[271,1522,1523,1538,1543,1548,1553,1558],{"__ignoreMap":301},[305,1524,1525,1527,1530,1533,1536],{"class":307,"line":308},[305,1526,273],{"class":585},[305,1528,1529],{"class":332}," --dead-code",[305,1531,1532],{"class":332}," --dead-code-categories",[305,1534,1535],{"class":332}," all",[305,1537,1067],{"class":332},[305,1539,1540],{"class":307,"line":341},[305,1541,1542],{"class":597},"# Unused files (1)\n",[305,1544,1545],{"class":307,"line":348},[305,1546,1547],{"class":597},"#  - src\u002Fadmin\u002Fpanel.js  certain 95%  3 lines\n",[305,1549,1550],{"class":307,"line":378},[305,1551,1552],{"class":597},"# Unused members (1)\n",[305,1554,1555],{"class":307,"line":447},[305,1556,1557],{"class":597},"#  - method src\u002Fcart.js:2:3 Cart.constructor  medium 70%  4 lines\n",[305,1559,1560],{"class":307,"line":470},[305,1561,1562],{"class":597},"# Found 2 dead code findings in 3 files (31.8% of 22 lines).\n",[259,1564,1565,1566,1569],{},"jscpd 5.4.3 prints ",[271,1567,1568],{},"No dead code found."," for the same project:",[1571,1572,1573,1610,1637],"ul",{},[1574,1575,1576,1579,1580,1583,1584,1587,1588,1591,1592,1595,1596,1599,1600,776,1605,782],"li",{},[271,1577,1578],{},"import()"," with backticks and nothing interpolated, such as ",[271,1581,1582],{},"import(`.\u002Fadmin\u002Fpanel.js`)",", is followed now, and so is ",[271,1585,1586],{},"import.meta.glob(`.\u002Fpages\u002F*.ts`)",". A quoted specifier with a ",[271,1589,1590],{},"$"," in it, such as SvelteKit's ",[271,1593,1594],{},"import('$lib\u002Fx')",", is followed too: only ",[271,1597,1598],{},"${"," inside backticks counts as interpolation. Before, the importing file also lost 30 points of confidence on all its findings (",[619,1601,1604],{"href":1602,"rel":1603},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1239",[623],"#1239",[619,1606,1609],{"href":1607,"rel":1608},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1251",[623],"#1251",[1574,1611,1612,1615,1616,1619,1620,1623,1624,770,1627,776,1632,782],{},[271,1613,1614],{},"constructor"," in JavaScript and dunder methods such as ",[271,1617,1618],{},"__init__"," or ",[271,1621,1622],{},"__repr__"," in Python are called by the runtime, not by name, so the unused-member check skips them. Fixed by ",[619,1625,769],{"href":767,"rel":1626},[623],[619,1628,1631],{"href":1629,"rel":1630},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1253",[623],"#1253",[619,1633,1636],{"href":1634,"rel":1635},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1254",[623],"#1254",[1574,1638,1639,282,1642,1645,1646,776,1651,782],{},[271,1640,1641],{},"knip.ts",[271,1643,1644],{},"knip.js"," are knip's config, and a new framework entry keeps them as entry points instead of unused files (",[619,1647,1650],{"href":1648,"rel":1649},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1255",[623],"#1255",[619,1652,1655],{"href":1653,"rel":1654},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1256",[623],"#1256",[259,1657,1658,1659,1661],{},"On six repositories that we checked with the ",[271,1660,1578],{}," fix, nothing new was reported.",[263,1663,1665],{"id":1664},"security-and-packaging","Security and packaging",[1571,1667,1668,1675,1678,1689],{},[1574,1669,1670,1671,1674],{},"The Linux binaries accepted certificates from the leaked emSign intermediate CAs. rustls-webpki 0.103.16 and webpki-roots 1.0.10 reject them. This matters only for ",[271,1672,1673],{},"--semantic-url"," with a remote API on Linux: model downloads are pinned by SHA-256, and macOS and Windows use the system TLS stack (RUSTSEC-2026-0381, 0382, 0383).",[1574,1676,1677],{},"candle 0.11.1 brings zip 9.3.0, which fixes RUSTSEC-2026-0429 and three zip advisories, and askama no longer pulls in the unmaintained basic-toml.",[1574,1679,1680,1683,1684,782],{},[271,1681,1682],{},"nix run github:kucherenko\u002Fjscpd"," builds again, and a Nix workflow builds and runs the package on Linux and macOS (",[619,1685,1688],{"href":1686,"rel":1687},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fpull\u002F1272",[623],"#1272",[1574,1690,1691,1692,1695,1696,770,1701,782],{},"The npmmirror registry never copied ",[271,1693,1694],{},"jscpd-linux-x64-gnu@5.4.2",", so pnpm installs through the mirror lost the Linux binary without a warning. The release pipeline asks the mirror to sync every package now. Reported by ",[619,1697,1700],{"href":1698,"rel":1699},"https:\u002F\u002Fgithub.com\u002Ficret",[623],"@icret",[619,1702,1705],{"href":1703,"rel":1704},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1261",[623],"#1261",[263,1707,1709],{"id":1708},"update","Update",[296,1711,1713],{"className":576,"code":1712,"language":578,"meta":301,"style":301},"curl -fsSL https:\u002F\u002Fjscpd.dev\u002Finstall.sh | bash\n# or\nnpm i -g jscpd@5\n",[271,1714,1715,1732,1737],{"__ignoreMap":301},[305,1716,1717,1720,1723,1726,1729],{"class":307,"line":308},[305,1718,1719],{"class":585},"curl",[305,1721,1722],{"class":332}," -fsSL",[305,1724,1725],{"class":332}," https:\u002F\u002Fjscpd.dev\u002Finstall.sh",[305,1727,1728],{"class":315}," |",[305,1730,1731],{"class":585}," bash\n",[305,1733,1734],{"class":307,"line":341},[305,1735,1736],{"class":597},"# or\n",[305,1738,1739,1742,1745,1748],{"class":307,"line":348},[305,1740,1741],{"class":585},"npm",[305,1743,1744],{"class":332}," i",[305,1746,1747],{"class":332}," -g",[305,1749,1750],{"class":332}," jscpd@5\n",[259,1752,1753,1754,1757,1758,1763,1764,776,1767,776,1770,776,1773,776,1776,282,1779,1782],{},"The full list is in the ",[619,1755,1756],{"href":201},"changelog"," and in the ",[619,1759,1762],{"href":1760,"rel":1761},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Freleases\u002Ftag\u002Fv5.4.3",[623],"release notes",". Thanks to ",[619,1765,624],{"href":621,"rel":1766},[623],[619,1768,769],{"href":767,"rel":1769},[623],[619,1771,763],{"href":761,"rel":1772},[623],[619,1774,1114],{"href":1112,"rel":1775},[623],[619,1777,678],{"href":676,"rel":1778},[623],[619,1780,1700],{"href":1698,"rel":1781},[623]," for the issues, the causes and the fixes in this release!",[1784,1785,1786],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}",{"title":301,"searchDepth":341,"depth":341,"links":1788},[1789,1790,1791,1792,1794,1795,1796,1797],{"id":265,"depth":341,"text":266},{"id":638,"depth":341,"text":639},{"id":687,"depth":341,"text":688},{"id":785,"depth":341,"text":1793},"jscpd:ignore regions with \u002F* in a string",{"id":1132,"depth":341,"text":1133},{"id":1201,"depth":341,"text":1202},{"id":1664,"depth":341,"text":1665},{"id":1708,"depth":341,"text":1709},"2026-11-12","runJscpd() for Node.js scripts, both fragments of a clone in the HTML report, an Action that installs the jscpd of its own tag, and fixes for jscpd:ignore regions and dead-code findings. With commands and real output.","md",{},"\u002Fblog\u002Fjscpd-5-4-3","2026-11-12T10:00:00Z",{"title":252,"description":1805},"jscpd 5.4.3 explained with examples: runJscpd() from the npm package, a side-by-side HTML report with highlighting, Action version pinning, jscpd:ignore regions with \u002F* in strings, and dead-code fixes for import() and constructors.","blog\u002Fjscpd-5-4-3",[1808],"release","uqNUcN2RE0dNFoajeR066zng3f4MMN-1uVbxe8ylnOA",{"id":1811,"title":1812,"authors":1813,"body":1814,"date":3137,"description":3138,"extension":1800,"meta":3139,"navigation":6,"path":3140,"publishedAt":3141,"seo":3142,"stem":3144,"tags":3145,"__hash__":3146},"blog\u002Fblog\u002Fjscpd-5-4-2.md","What's new in jscpd 5.4.2",[254],{"type":256,"value":1815,"toc":3128},[1816,1829,1833,1836,1843,2024,2039,2042,2105,2112,2158,2384,2402,2413,2417,2423,2483,2498,2501,2576,2618,2635,2639,2644,2721,2746,2798,2812,2816,2828,2836,2859,2863,2895,2956,2999,3003,3084,3086,3116,3125],[259,1817,1818,1819,1822,1823,1828],{},"5.4.2 adds boundary rules, makes the search for renamed copies strict about names, puts the health score into ",[271,1820,1821],{},"--history"," and knows 73 more formats. Every example below runs on a demo folder from the ",[619,1824,1827],{"href":1825,"rel":1826},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Ftree\u002Fmaster\u002Ffixtures",[623],"fixtures of the repository",", so you can repeat it on your machine.",[263,1830,1832],{"id":1831},"keep-the-code-of-a-module-inside-it","Keep the code of a module inside it",[259,1834,1835],{},"Some code belongs in one place. In a shop that also gives loans, the backend calculates every amount it charges. A discount or a monthly payment that the web app calculates too is a second version of a backend function, and when the formula changes on the backend, the copy keeps the old one. Import linters such as dependency-cruiser or ArchUnit check who imports whom. A copied function imports nothing, so they don't see it.",[259,1837,1838,1839,1842],{},"A boundary rule in ",[271,1840,1841],{},".jscpd.json"," names the code to protect and the places its copies must stay out of:",[296,1844,1848],{"className":1845,"code":1846,"language":1847,"meta":301,"style":301},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"boundaries\": [\n    {\n      \"name\": \"money\",\n      \"code\": [\"backend\u002Fpricing\", \"backend\u002Floans\u002FInterest.kt#monthlyPayment\"],\n      \"notIn\": [\"web\u002F**\"],\n      \"allow\": [\"web\u002Fe2e\u002F**\"],\n      \"thresholds\": { \"minTokens\": 30, \"similarity\": 0.7 }\n    }\n  ]\n}\n","json",[271,1849,1850,1854,1868,1873,1894,1925,1947,1969,2010,2015,2020],{"__ignoreMap":301},[305,1851,1852],{"class":307,"line":308},[305,1853,496],{"class":315},[305,1855,1856,1859,1862,1864,1866],{"class":307,"line":341},[305,1857,1858],{"class":315},"  \"",[305,1860,1861],{"class":351},"boundaries",[305,1863,335],{"class":315},[305,1865,457],{"class":315},[305,1867,822],{"class":315},[305,1869,1870],{"class":307,"line":348},[305,1871,1872],{"class":315},"    {\n",[305,1874,1875,1878,1881,1883,1885,1887,1890,1892],{"class":307,"line":378},[305,1876,1877],{"class":315},"      \"",[305,1879,1880],{"class":585},"name",[305,1882,335],{"class":315},[305,1884,457],{"class":315},[305,1886,329],{"class":315},[305,1888,1889],{"class":332},"money",[305,1891,335],{"class":315},[305,1893,444],{"class":315},[305,1895,1896,1898,1900,1902,1904,1906,1908,1911,1913,1915,1917,1920,1922],{"class":307,"line":447},[305,1897,1877],{"class":315},[305,1899,271],{"class":585},[305,1901,335],{"class":315},[305,1903,457],{"class":315},[305,1905,848],{"class":315},[305,1907,335],{"class":315},[305,1909,1910],{"class":332},"backend\u002Fpricing",[305,1912,335],{"class":315},[305,1914,360],{"class":315},[305,1916,329],{"class":315},[305,1918,1919],{"class":332},"backend\u002Floans\u002FInterest.kt#monthlyPayment",[305,1921,335],{"class":315},[305,1923,1924],{"class":315},"],\n",[305,1926,1927,1929,1932,1934,1936,1938,1940,1943,1945],{"class":307,"line":470},[305,1928,1877],{"class":315},[305,1930,1931],{"class":585},"notIn",[305,1933,335],{"class":315},[305,1935,457],{"class":315},[305,1937,848],{"class":315},[305,1939,335],{"class":315},[305,1941,1942],{"class":332},"web\u002F**",[305,1944,335],{"class":315},[305,1946,1924],{"class":315},[305,1948,1949,1951,1954,1956,1958,1960,1962,1965,1967],{"class":307,"line":478},[305,1950,1877],{"class":315},[305,1952,1953],{"class":585},"allow",[305,1955,335],{"class":315},[305,1957,457],{"class":315},[305,1959,848],{"class":315},[305,1961,335],{"class":315},[305,1963,1964],{"class":332},"web\u002Fe2e\u002F**",[305,1966,335],{"class":315},[305,1968,1924],{"class":315},[305,1970,1971,1973,1976,1978,1980,1982,1984,1987,1989,1991,1994,1996,1998,2001,2003,2005,2008],{"class":307,"line":499},[305,1972,1877],{"class":315},[305,1974,1975],{"class":585},"thresholds",[305,1977,335],{"class":315},[305,1979,457],{"class":315},[305,1981,316],{"class":315},[305,1983,329],{"class":315},[305,1985,1986],{"class":390},"minTokens",[305,1988,335],{"class":315},[305,1990,457],{"class":315},[305,1992,1993],{"class":390}," 30",[305,1995,360],{"class":315},[305,1997,329],{"class":315},[305,1999,2000],{"class":390},"similarity",[305,2002,335],{"class":315},[305,2004,457],{"class":315},[305,2006,2007],{"class":390}," 0.7",[305,2009,467],{"class":315},[305,2011,2012],{"class":307,"line":526},[305,2013,2014],{"class":315},"    }\n",[305,2016,2017],{"class":307,"line":546},[305,2018,2019],{"class":315},"  ]\n",[305,2021,2022],{"class":307,"line":552},[305,2023,549],{"class":315},[259,2025,2026,2028,2029,2032,2033,2035,2036,2038],{},[271,2027,271],{}," takes a folder, a file, a glob, or one method as ",[271,2030,2031],{},"path#name",". ",[271,2034,1953],{}," lets the end-to-end tests keep their copy of the discount, and ",[271,2037,1975],{}," looks for smaller and looser copies than the clone report does, because for money code a missed copy costs more than a false alarm.",[259,2040,2041],{},"Every clone run checks the rules. The demo web app has three copies:",[296,2043,2045],{"className":576,"code":2044,"language":578,"meta":301,"style":301},"jscpd --config fixtures\u002Fboundaries-demo\u002F.jscpd.json fixtures\u002Fboundaries-demo\n# Boundaries:\n# money: 3 copies outside the boundary\n#   web\u002Fsrc\u002Fcheckout\u002Fdiscount.ts:8-17 applyDiscount\n#     copy of backend\u002Fpricing\u002Fdiscount.ts:6-15 applyDiscount (exact, 10 lines)\n#   web\u002Fsrc\u002Fcheckout\u002Ftax.ts:6-15 estimateTax\n#     looks like backend\u002Fpricing\u002Ftax.ts:5-13 salesTax (similar (ast) ~0.84)\n#   web\u002Fsrc\u002Floan\u002Fpayment.ts:4-14 monthlyPayment\n#     looks like backend\u002Floans\u002FInterest.kt:8-15 monthlyPayment (semantic ~0.82)\n# ERROR: jscpd found 3 copies of protected code outside their boundaries (money: 3)\n",[271,2046,2047,2060,2065,2070,2075,2080,2085,2090,2095,2100],{"__ignoreMap":301},[305,2048,2049,2051,2054,2057],{"class":307,"line":308},[305,2050,273],{"class":585},[305,2052,2053],{"class":332}," --config",[305,2055,2056],{"class":332}," fixtures\u002Fboundaries-demo\u002F.jscpd.json",[305,2058,2059],{"class":332}," fixtures\u002Fboundaries-demo\n",[305,2061,2062],{"class":307,"line":341},[305,2063,2064],{"class":597},"# Boundaries:\n",[305,2066,2067],{"class":307,"line":348},[305,2068,2069],{"class":597},"# money: 3 copies outside the boundary\n",[305,2071,2072],{"class":307,"line":378},[305,2073,2074],{"class":597},"#   web\u002Fsrc\u002Fcheckout\u002Fdiscount.ts:8-17 applyDiscount\n",[305,2076,2077],{"class":307,"line":447},[305,2078,2079],{"class":597},"#     copy of backend\u002Fpricing\u002Fdiscount.ts:6-15 applyDiscount (exact, 10 lines)\n",[305,2081,2082],{"class":307,"line":470},[305,2083,2084],{"class":597},"#   web\u002Fsrc\u002Fcheckout\u002Ftax.ts:6-15 estimateTax\n",[305,2086,2087],{"class":307,"line":478},[305,2088,2089],{"class":597},"#     looks like backend\u002Fpricing\u002Ftax.ts:5-13 salesTax (similar (ast) ~0.84)\n",[305,2091,2092],{"class":307,"line":499},[305,2093,2094],{"class":597},"#   web\u002Fsrc\u002Floan\u002Fpayment.ts:4-14 monthlyPayment\n",[305,2096,2097],{"class":307,"line":526},[305,2098,2099],{"class":597},"#     looks like backend\u002Floans\u002FInterest.kt:8-15 monthlyPayment (semantic ~0.82)\n",[305,2101,2102],{"class":307,"line":546},[305,2103,2104],{"class":597},"# ERROR: jscpd found 3 copies of protected code outside their boundaries (money: 3)\n",[259,2106,2107,2108,2111],{},"jscpd found each copy a different way. The discount is copy-paste, a token clone. The tax has other names and a debug line, and the structure comparison of ",[271,2109,2110],{},"--similarity"," finds it. The monthly payment is the Kotlin method written again in TypeScript:",[296,2113,2117],{"className":2114,"code":2115,"language":2116,"meta":301,"style":301},"language-kotlin shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","fun monthlyPayment(principalCents: Long, annualRatePercent: Double, months: Int): Long {\n    if (months \u003C= 0) return principalCents\n    val monthlyRate = annualRatePercent \u002F 100.0 \u002F 12.0\n    if (monthlyRate == 0.0) return principalCents \u002F months\n    val factor = (1 + monthlyRate).pow(months)\n    val payment = principalCents * monthlyRate * factor \u002F (factor - 1)\n    return payment.roundToLong()\n}\n","kotlin",[271,2118,2119,2124,2129,2134,2139,2144,2149,2154],{"__ignoreMap":301},[305,2120,2121],{"class":307,"line":308},[305,2122,2123],{},"fun monthlyPayment(principalCents: Long, annualRatePercent: Double, months: Int): Long {\n",[305,2125,2126],{"class":307,"line":341},[305,2127,2128],{},"    if (months \u003C= 0) return principalCents\n",[305,2130,2131],{"class":307,"line":348},[305,2132,2133],{},"    val monthlyRate = annualRatePercent \u002F 100.0 \u002F 12.0\n",[305,2135,2136],{"class":307,"line":378},[305,2137,2138],{},"    if (monthlyRate == 0.0) return principalCents \u002F months\n",[305,2140,2141],{"class":307,"line":447},[305,2142,2143],{},"    val factor = (1 + monthlyRate).pow(months)\n",[305,2145,2146],{"class":307,"line":470},[305,2147,2148],{},"    val payment = principalCents * monthlyRate * factor \u002F (factor - 1)\n",[305,2150,2151],{"class":307,"line":478},[305,2152,2153],{},"    return payment.roundToLong()\n",[305,2155,2156],{"class":307,"line":499},[305,2157,549],{},[296,2159,2161],{"className":796,"code":2160,"language":798,"meta":301,"style":301},"export function monthlyPayment(principal: number, yearlyRate: number, termMonths: number): number {\n  if (termMonths \u003C= 0) {\n    return principal;\n  }\n  const r = yearlyRate \u002F 100 \u002F 12;\n  if (r === 0) {\n    return principal \u002F termMonths;\n  }\n  const growth = Math.pow(1 + r, termMonths);\n  return Math.round((principal * r * growth) \u002F (growth - 1));\n}\n",[271,2162,2163,2207,2226,2236,2240,2264,2282,2294,2298,2333,2380],{"__ignoreMap":301},[305,2164,2165,2167,2169,2172,2174,2177,2179,2182,2184,2187,2189,2191,2193,2196,2198,2200,2203,2205],{"class":307,"line":308},[305,2166,810],{"class":311},[305,2168,1329],{"class":351},[305,2170,2171],{"class":372}," monthlyPayment",[305,2173,510],{"class":315},[305,2175,2176],{"class":1431},"principal",[305,2178,457],{"class":315},[305,2180,2181],{"class":585}," number",[305,2183,360],{"class":315},[305,2185,2186],{"class":1431}," yearlyRate",[305,2188,457],{"class":315},[305,2190,2181],{"class":585},[305,2192,360],{"class":315},[305,2194,2195],{"class":1431}," termMonths",[305,2197,457],{"class":315},[305,2199,2181],{"class":585},[305,2201,2202],{"class":315},"):",[305,2204,2181],{"class":585},[305,2206,1338],{"class":315},[305,2208,2209,2212,2214,2217,2220,2222,2224],{"class":307,"line":341},[305,2210,2211],{"class":311},"  if",[305,2213,770],{"class":453},[305,2215,2216],{"class":319},"termMonths",[305,2218,2219],{"class":315}," \u003C=",[305,2221,490],{"class":390},[305,2223,493],{"class":453},[305,2225,496],{"class":315},[305,2227,2228,2231,2234],{"class":307,"line":348},[305,2229,2230],{"class":311},"    return",[305,2232,2233],{"class":319}," principal",[305,2235,338],{"class":315},[305,2237,2238],{"class":307,"line":378},[305,2239,1469],{"class":315},[305,2241,2242,2244,2247,2249,2251,2254,2257,2259,2262],{"class":307,"line":447},[305,2243,1343],{"class":351},[305,2245,2246],{"class":319}," r",[305,2248,369],{"class":315},[305,2250,2186],{"class":319},[305,2252,2253],{"class":315}," \u002F",[305,2255,2256],{"class":390}," 100",[305,2258,2253],{"class":315},[305,2260,2261],{"class":390}," 12",[305,2263,338],{"class":315},[305,2265,2266,2268,2270,2273,2276,2278,2280],{"class":307,"line":470},[305,2267,2211],{"class":311},[305,2269,770],{"class":453},[305,2271,2272],{"class":319},"r",[305,2274,2275],{"class":315}," ===",[305,2277,490],{"class":390},[305,2279,493],{"class":453},[305,2281,496],{"class":315},[305,2283,2284,2286,2288,2290,2292],{"class":307,"line":478},[305,2285,2230],{"class":311},[305,2287,2233],{"class":319},[305,2289,2253],{"class":315},[305,2291,2195],{"class":319},[305,2293,338],{"class":315},[305,2295,2296],{"class":307,"line":499},[305,2297,1469],{"class":315},[305,2299,2300,2302,2305,2307,2310,2312,2315,2317,2320,2323,2325,2327,2329,2331],{"class":307,"line":526},[305,2301,1343],{"class":351},[305,2303,2304],{"class":319}," growth",[305,2306,369],{"class":315},[305,2308,2309],{"class":319}," Math",[305,2311,384],{"class":315},[305,2313,2314],{"class":372},"pow",[305,2316,510],{"class":453},[305,2318,2319],{"class":390},"1",[305,2321,2322],{"class":315}," +",[305,2324,2246],{"class":319},[305,2326,360],{"class":315},[305,2328,2195],{"class":319},[305,2330,473],{"class":453},[305,2332,338],{"class":315},[305,2334,2335,2338,2340,2342,2345,2348,2350,2353,2355,2357,2359,2361,2364,2366,2369,2372,2375,2378],{"class":307,"line":546},[305,2336,2337],{"class":311},"  return",[305,2339,2309],{"class":319},[305,2341,384],{"class":315},[305,2343,2344],{"class":372},"round",[305,2346,2347],{"class":453},"((",[305,2349,2176],{"class":319},[305,2351,2352],{"class":315}," *",[305,2354,2246],{"class":319},[305,2356,2352],{"class":315},[305,2358,2304],{"class":319},[305,2360,493],{"class":453},[305,2362,2363],{"class":315},"\u002F",[305,2365,770],{"class":453},[305,2367,2368],{"class":319},"growth",[305,2370,2371],{"class":315}," -",[305,2373,2374],{"class":390}," 1",[305,2376,2377],{"class":453},"))",[305,2379,338],{"class":315},[305,2381,2382],{"class":307,"line":552},[305,2383,549],{"class":315},[259,2385,2386,2387,2390,2391,2032,2394,2397,2398,2401],{},"Tokens and syntax trees don't match across Kotlin and TypeScript, so the rules pair functions the way ",[271,2388,2389],{},"--compare"," does, with the embedding model of ",[271,2392,2393],{},"--semantic",[271,2395,2396],{},"jscpd --semantic-download"," gets it once, 548 MB. Without the model jscpd prints a warning and checks the rules without it, and here it finds the first two copies. A rule with ",[271,2399,2400],{},"\"disable\": [\"semantic\"]"," needs no model at all.",[259,2403,2404,2405,2408,2409,2412],{},"The run exits with code 1, so a rule is a CI gate as it is. The console, ai and json reporters show the violations. Baselines, ",[271,2406,2407],{},"--changed",", SARIF, the language server and the MCP server don't know about the rules yet, they come next. The ",[619,2410,2411],{"href":101},"boundaries guide"," has every key, the errors and warnings, and a CI job.",[263,2414,2416],{"id":2415},"renamed-copies-that-are-really-renamed","Renamed copies that are really renamed",[259,2418,2419,2422],{},[271,2420,2421],{},"--ignore-identifiers"," used to turn every name into the same placeholder, so any name matched any other. These two functions came out as a clone:",[296,2424,2428],{"className":2425,"code":2426,"language":2427,"meta":301,"style":301},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","def compute(a, b, c):\n    d = a + b * c\n    e = d - a \u002F b\n    f = e * c + d\n    ...\n\ndef evaluate(x, y, z):\n    d = x + x * x\n    e = d - x \u002F x\n    f = e * x + d\n    ...\n","python",[271,2429,2430,2435,2440,2445,2450,2455,2459,2464,2469,2474,2479],{"__ignoreMap":301},[305,2431,2432],{"class":307,"line":308},[305,2433,2434],{},"def compute(a, b, c):\n",[305,2436,2437],{"class":307,"line":341},[305,2438,2439],{},"    d = a + b * c\n",[305,2441,2442],{"class":307,"line":348},[305,2443,2444],{},"    e = d - a \u002F b\n",[305,2446,2447],{"class":307,"line":378},[305,2448,2449],{},"    f = e * c + d\n",[305,2451,2452],{"class":307,"line":447},[305,2453,2454],{},"    ...\n",[305,2456,2457],{"class":307,"line":470},[305,2458,345],{"emptyLinePlaceholder":344},[305,2460,2461],{"class":307,"line":478},[305,2462,2463],{},"def evaluate(x, y, z):\n",[305,2465,2466],{"class":307,"line":499},[305,2467,2468],{},"    d = x + x * x\n",[305,2470,2471],{"class":307,"line":526},[305,2472,2473],{},"    e = d - x \u002F x\n",[305,2475,2476],{"class":307,"line":546},[305,2477,2478],{},"    f = e * x + d\n",[305,2480,2481],{"class":307,"line":552},[305,2482,2454],{},[259,2484,2485,2486,2491,2492,2497],{},"They have the same shape, and the data flows through them another way. ",[619,2487,2490],{"href":2488,"rel":2489},"https:\u002F\u002Fgithub.com\u002Fsoodoku",[623],"@soodoku"," opened ",[619,2493,2496],{"href":2494,"rel":2495},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1217",[623],"an issue"," about it, with numbers from Django and scikit-learn. I checked 24 projects in 11 languages: 6,942 of their 14,501 renamed clones had no one-to-one mapping between the names. Most of them were import lists, a list matched with itself shifted by a line, or statements that only look alike.",[259,2499,2500],{},"Now a name on one side has to stand for the same name on the other side every time, and two names can't stand for one:",[296,2502,2504],{"className":576,"code":2503,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Ftype2-demo\u002Fconsistent\u002Fpython --ignore-identifiers=blind\n# Clone found (python, renamed)\n#  - one.py [1:1 - 8:13] (8 lines, 54 tokens)\n#    three.py [1:1 - 8:13]\n# Clone found (python, renamed)\n#  - one.py [1:1 - 8:13] (8 lines, 54 tokens)\n#    two.py [1:1 - 8:13]\n# Found 2 clones.\njscpd fixtures\u002Ftype2-demo\u002Fconsistent\u002Fpython --ignore-identifiers\n# Clone found (python, renamed)\n#  - one.py [1:1 - 8:13] (8 lines, 54 tokens)\n#    two.py [1:1 - 8:13]\n# Found 1 clones.\n",[271,2505,2506,2516,2521,2526,2531,2535,2539,2544,2549,2558,2562,2566,2571],{"__ignoreMap":301},[305,2507,2508,2510,2513],{"class":307,"line":308},[305,2509,273],{"class":585},[305,2511,2512],{"class":332}," fixtures\u002Ftype2-demo\u002Fconsistent\u002Fpython",[305,2514,2515],{"class":332}," --ignore-identifiers=blind\n",[305,2517,2518],{"class":307,"line":341},[305,2519,2520],{"class":597},"# Clone found (python, renamed)\n",[305,2522,2523],{"class":307,"line":348},[305,2524,2525],{"class":597},"#  - one.py [1:1 - 8:13] (8 lines, 54 tokens)\n",[305,2527,2528],{"class":307,"line":378},[305,2529,2530],{"class":597},"#    three.py [1:1 - 8:13]\n",[305,2532,2533],{"class":307,"line":447},[305,2534,2520],{"class":597},[305,2536,2537],{"class":307,"line":470},[305,2538,2525],{"class":597},[305,2540,2541],{"class":307,"line":478},[305,2542,2543],{"class":597},"#    two.py [1:1 - 8:13]\n",[305,2545,2546],{"class":307,"line":499},[305,2547,2548],{"class":597},"# Found 2 clones.\n",[305,2550,2551,2553,2555],{"class":307,"line":526},[305,2552,273],{"class":585},[305,2554,2512],{"class":332},[305,2556,2557],{"class":332}," --ignore-identifiers\n",[305,2559,2560],{"class":307,"line":546},[305,2561,2520],{"class":597},[305,2563,2564],{"class":307,"line":552},[305,2565,2525],{"class":597},[305,2567,2569],{"class":307,"line":2568},12,[305,2570,2543],{"class":597},[305,2572,2574],{"class":307,"line":2573},13,[305,2575,1087],{"class":597},[259,2577,2578,2581,2582,2585,2586,2589,2590,2593,2594,2597,2598,2601,2602,2605,2606,2609,2610,2612,2613,679,2615,384],{},[271,2579,2580],{},"two.py"," renames every name of ",[271,2583,2584],{},"one.py"," one for one, ",[271,2587,2588],{},"three.py"," is ",[271,2591,2592],{},"evaluate"," from above, and ",[271,2595,2596],{},"=blind"," is the old matching. A member is a name apart from a local of the same text, so a constructor that sets ",[271,2599,2600],{},"this.url = url"," still matches its copy that sets ",[271,2603,2604],{},"this.url = address",": the field ",[271,2607,2608],{},"url"," stands for the field ",[271,2611,2608],{},", and the parameter ",[271,2614,2608],{},[271,2616,2617],{},"address",[259,2619,2620,2621,2623,2624,2626,2627,2630,2631,2634],{},"After the update ",[271,2622,2421],{}," reports fewer renamed clones, and some of them are shorter, because jscpd cuts a clone where a name starts to stand for two. A baseline that 5.4 made with ",[271,2625,2421],{}," holds the old clones. Keep ",[271,2628,2629],{},"--ignore-identifiers=blind"," with it or update it, otherwise ",[271,2632,2633],{},"--fail-on-new-clones"," counts the cut clones as new.",[263,2636,2638],{"id":2637},"the-same-rule-in-similarity","The same rule in --similarity",[259,2640,2641,2643],{},[271,2642,2110],{}," had the same blind spot, every local name became one marker. Now the fingerprint of a subtree also records how its names repeat. Two functions from the demo:",[296,2645,2647],{"className":2425,"code":2646,"language":2427,"meta":301,"style":301},"def clamp_low(values, floor):\n    result = []\n    for value in values:\n        if value \u003C floor:\n            value = floor\n        result.append(value)\n    return result\n\ndef clamp_high(values, ceiling):\n    result = []\n    for value in values:\n        if ceiling \u003C value:\n            value = ceiling\n        result.append(value)\n    return result\n",[271,2648,2649,2654,2659,2664,2669,2674,2679,2684,2688,2693,2697,2701,2706,2711,2716],{"__ignoreMap":301},[305,2650,2651],{"class":307,"line":308},[305,2652,2653],{},"def clamp_low(values, floor):\n",[305,2655,2656],{"class":307,"line":341},[305,2657,2658],{},"    result = []\n",[305,2660,2661],{"class":307,"line":348},[305,2662,2663],{},"    for value in values:\n",[305,2665,2666],{"class":307,"line":378},[305,2667,2668],{},"        if value \u003C floor:\n",[305,2670,2671],{"class":307,"line":447},[305,2672,2673],{},"            value = floor\n",[305,2675,2676],{"class":307,"line":470},[305,2677,2678],{},"        result.append(value)\n",[305,2680,2681],{"class":307,"line":478},[305,2682,2683],{},"    return result\n",[305,2685,2686],{"class":307,"line":499},[305,2687,345],{"emptyLinePlaceholder":344},[305,2689,2690],{"class":307,"line":526},[305,2691,2692],{},"def clamp_high(values, ceiling):\n",[305,2694,2695],{"class":307,"line":546},[305,2696,2658],{},[305,2698,2699],{"class":307,"line":552},[305,2700,2663],{},[305,2702,2703],{"class":307,"line":2568},[305,2704,2705],{},"        if ceiling \u003C value:\n",[305,2707,2708],{"class":307,"line":2573},[305,2709,2710],{},"            value = ceiling\n",[305,2712,2714],{"class":307,"line":2713},14,[305,2715,2678],{},[305,2717,2719],{"class":307,"line":2718},15,[305,2720,2683],{},[259,2722,2723,2724,2727,2728,2731,2732,2734,2735,2737,2738,2741,2742,2745],{},"They are made of the same markers, but the comparison is mirrored, so ",[271,2725,2726],{},"value"," would stand for ",[271,2729,2730],{},"ceiling"," in the ",[271,2733,481],{}," and for ",[271,2736,2726],{}," in the assignment. A renamed copy of ",[271,2739,2740],{},"clamp_low"," still scores 1.00, and ",[271,2743,2744],{},"clamp_high"," scores 0.74, under the default bar of 0.8:",[296,2747,2749],{"className":576,"code":2748,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Fsimilarity-demo\u002Fnames --similarity 0.7\n# Clone found (python, similar (ast) ~0.74)\n#  - clamp_high.py [1:1 - 7:18] (7 lines, 33 tokens)\n#    clamp_low.py [1:1 - 7:18]\n# Clone found (python, similar (ast) ~1.00)\n#  - clamp_low.py [1:1 - 7:18] (7 lines, 33 tokens)\n#    limit_low.py [1:1 - 7:16]\n# Found 2 clones.\n",[271,2750,2751,2764,2769,2774,2779,2784,2789,2794],{"__ignoreMap":301},[305,2752,2753,2755,2758,2761],{"class":307,"line":308},[305,2754,273],{"class":585},[305,2756,2757],{"class":332}," fixtures\u002Fsimilarity-demo\u002Fnames",[305,2759,2760],{"class":332}," --similarity",[305,2762,2763],{"class":390}," 0.7\n",[305,2765,2766],{"class":307,"line":341},[305,2767,2768],{"class":597},"# Clone found (python, similar (ast) ~0.74)\n",[305,2770,2771],{"class":307,"line":348},[305,2772,2773],{"class":597},"#  - clamp_high.py [1:1 - 7:18] (7 lines, 33 tokens)\n",[305,2775,2776],{"class":307,"line":378},[305,2777,2778],{"class":597},"#    clamp_low.py [1:1 - 7:18]\n",[305,2780,2781],{"class":307,"line":447},[305,2782,2783],{"class":597},"# Clone found (python, similar (ast) ~1.00)\n",[305,2785,2786],{"class":307,"line":470},[305,2787,2788],{"class":597},"#  - clamp_low.py [1:1 - 7:18] (7 lines, 33 tokens)\n",[305,2790,2791],{"class":307,"line":478},[305,2792,2793],{"class":597},"#    limit_low.py [1:1 - 7:16]\n",[305,2795,2796],{"class":307,"line":499},[305,2797,2548],{"class":597},[259,2799,2800,2801,2804,2805,2808,2809,2811],{},"Fields, keyword arguments, object keys and types keep names of their own, so ",[271,2802,2803],{},"self.url = url"," still matches ",[271,2806,2807],{},"self.url = link",". On the same 24 projects 15 of 23,530 pairs fell below 0.8, and runs take 2 to 9% longer. ",[271,2810,2629],{}," brings the old scores back.",[263,2813,2815],{"id":2814},"health-in-history","Health in --history",[259,2817,2818,2820,2821,2824,2825,2827],{},[271,2819,1821],{}," scans every commit of a range and prints the trend of duplication. Now every point also gets the health score that ",[271,2822,2823],{},"jscpd --health"," gives its tree, and a bare ",[271,2826,1821],{}," walks the last 30 commits of the branch. The demo repository has four commits: a function, two copies of it, and then an import instead of one copy:",[296,2829,2834],{"className":2830,"code":2832,"language":2833,"meta":301},[2831],"language-text","  #  COMMIT   DATE        FILES  LINES  CLONES  DUP LINES   DUP%  CHANGE  HEALTH  CHANGE  SUBJECT\n  1  3ba9acb  2026-08-01      1     11       0          0   0.0%            74 B          initial helpers\n  2  3ac98f6  2026-08-08      2     21       1         10  47.6%   +47.6    72 B      -2  copy total() into b.js\n  3  5cec522  2026-08-15      3     31       2         20  64.5%   +16.9    70 B      -2  and again into c.js\n  4  fe3f38a  2026-08-22      2     21       1         10  47.6%   -16.9    72 B      +2  b.js imports total() instead\n  5  working  2026-10-20      2     21       1         10  47.6%       =    72 B       =  (uncommitted changes)\nTrend: +47.6 points since 3ba9acb (2026-08-01)\nHealth: -2 since 3ba9acb (2026-08-01), 74 B → 72 B: duplication 75 → 72, dead code 72 → 68, complexity 75 → 75\n","text",[271,2835,2832],{"__ignoreMap":301},[259,2837,2838,2839,2842,2843,282,2846,2849,2850,2855,2856,384],{},"Above the table jscpd draws two bar charts, one for duplication and one for health, and the ",[271,2840,2841],{},"Health:"," line says which dimension moved the score. ",[271,2844,2845],{},"jscpd --health --history",[271,2847,2848],{},"jscpd --dashboard --history"," print the badge or the dashboard first and the series under it, in the HTML report too. The walk follows first parents now, so a merged branch counts as its merge commit. The last 30 commits of axios take about 5.4 seconds, against 4.9 without the health score. The script that builds the demo repository is in ",[619,2851,2854],{"href":2852,"rel":2853},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Ftree\u002Fmaster\u002Ffixtures\u002Fhistory-demo",[623],"fixtures\u002Fhistory-demo",", and the options are in the ",[619,2857,2858],{"href":71},"history guide",[263,2860,2862],{"id":2861},"dockerfiles-makefiles-and-73-more-formats","Dockerfiles, Makefiles and 73 more formats",[259,2864,2865,2866,2869,2870,2873,2874,776,2877,776,2880,776,2883,776,2885,776,2888,776,2891,2894],{},"94 of 224 formats had no built-in extension, a gap jscpd carried over from v4, so ",[271,2867,2868],{},"jscpd ."," skipped Dockerfiles, Makefiles, ",[271,2871,2872],{},"go.mod",", Elixir and Nix files unless you mapped them by hand. The new extensions come from GitHub Linguist, and a table of file names knows ",[271,2875,2876],{},"Dockerfile",[271,2878,2879],{},"Containerfile",[271,2881,2882],{},"Makefile",[271,2884,2872],{},[271,2886,2887],{},"CMakeLists.txt",[271,2889,2890],{},"Gemfile",[271,2892,2893],{},"Jenkinsfile"," and others:",[296,2896,2898],{"className":576,"code":2897,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Ffile-names-demo\n# Clone found (elixir)\n#  - lib\u002Fshop\u002Finvoice_totals.ex [4:3 - 20:4] (17 lines, 116 tokens)\n#    lib\u002Fshop\u002Frefund_totals.ex [4:3 - 20:4]\n# Clone found (docker)\n#  - services\u002Fapi\u002FDockerfile [1:1 - 13:9] (13 lines, 94 tokens)\n#    services\u002Fworker\u002FDockerfile [1:1 - 13:9]\n# Clone found (makefile)\n#  - services\u002Fapi\u002FMakefile [3:1 - 21:22] (19 lines, 104 tokens)\n#    services\u002Fworker\u002FMakefile [3:1 - 21:22]\n# Found 3 clones.\n",[271,2899,2900,2906,2911,2916,2921,2926,2931,2936,2941,2946,2951],{"__ignoreMap":301},[305,2901,2902,2904],{"class":307,"line":308},[305,2903,273],{"class":585},[305,2905,660],{"class":332},[305,2907,2908],{"class":307,"line":341},[305,2909,2910],{"class":597},"# Clone found (elixir)\n",[305,2912,2913],{"class":307,"line":348},[305,2914,2915],{"class":597},"#  - lib\u002Fshop\u002Finvoice_totals.ex [4:3 - 20:4] (17 lines, 116 tokens)\n",[305,2917,2918],{"class":307,"line":378},[305,2919,2920],{"class":597},"#    lib\u002Fshop\u002Frefund_totals.ex [4:3 - 20:4]\n",[305,2922,2923],{"class":307,"line":447},[305,2924,2925],{"class":597},"# Clone found (docker)\n",[305,2927,2928],{"class":307,"line":470},[305,2929,2930],{"class":597},"#  - services\u002Fapi\u002FDockerfile [1:1 - 13:9] (13 lines, 94 tokens)\n",[305,2932,2933],{"class":307,"line":478},[305,2934,2935],{"class":597},"#    services\u002Fworker\u002FDockerfile [1:1 - 13:9]\n",[305,2937,2938],{"class":307,"line":499},[305,2939,2940],{"class":597},"# Clone found (makefile)\n",[305,2942,2943],{"class":307,"line":526},[305,2944,2945],{"class":597},"#  - services\u002Fapi\u002FMakefile [3:1 - 21:22] (19 lines, 104 tokens)\n",[305,2947,2948],{"class":307,"line":546},[305,2949,2950],{"class":597},"#    services\u002Fworker\u002FMakefile [3:1 - 21:22]\n",[305,2952,2953],{"class":307,"line":552},[305,2954,2955],{"class":597},"# Found 3 clones.\n",[259,2957,2958,2959,2961,2962,2964,2965,776,2968,2971,2972,2974,2975,2977,2978,1619,2981,2984,2985,679,2990,2994,2995,2998],{},"jscpd 5.4.1 prints ",[271,2960,1108],{}," for the same folder. So the numbers of an existing setup can move: on 22 repositories ",[271,2963,2868],{}," picked up 1 to 5 more files each, mostly Dockerfiles, ",[271,2966,2967],{},".editorconfig",[271,2969,2970],{},".jsonc",", Makefiles and ",[271,2973,2872],{},". Check a ",[271,2976,419],{}," gate after the update. A mapping of your own in ",[271,2979,2980],{},"--formats-exts",[271,2982,2983],{},"--formats-names"," still wins. Thanks to ",[619,2986,2989],{"href":2987,"rel":2988},"https:\u002F\u002Fgithub.com\u002Fpygarap",[623],"@pygarap",[619,2991,684],{"href":2992,"rel":2993},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Fissues\u002F1174",[623],". The ",[619,2996,2997],{"href":183},"supported formats"," page lists every name and extension.",[263,3000,3002],{"id":3001},"smaller-things","Smaller things",[1571,3004,3005,3020,3023,3026,3041,3051,3066,3073],{},[1574,3006,3007,3008,3011,3012,3015,3016,3019],{},"The MCP server's ",[271,3009,3010],{},"check_duplication"," matched no Vue, Svelte or Astro snippet, by tokens or by meaning. It splits a snippet into blocks now, the way a scan splits a file, and each match says its ",[271,3013,3014],{},"format"," and how many ",[271,3017,3018],{},"lines"," match.",[1574,3021,3022],{},"A Markdown page whose front matter ran into a code fence crashed jscpd with exit code 134, and took the MCP and language servers down with it.",[1574,3024,3025],{},"jscpd read a Razor view out of order, the HTML first and then the C#, so a clone across that seam ended before it started.",[1574,3027,3028,3030,3031,3034,3035,3040],{},[271,3029,1821],{}," failed when git's ",[271,3032,3033],{},"log.showSignature"," was on. ",[619,3036,3039],{"href":3037,"rel":3038},"https:\u002F\u002Fgithub.com\u002Fvitorcsbrito",[623],"@vitorcsbrito"," reported it with an exact reproduction.",[1574,3042,3043,3045,3046,384],{},[271,3044,2389],{}," paired a function with every near-best lookalike, now a function keeps one counterpart. On Lucene and Lucene.NET the share of pairs between files of the same name went from 46% to 73%. The analysis and the numbers are from ",[619,3047,3050],{"href":3048,"rel":3049},"https:\u002F\u002Fgithub.com\u002FMysterionRise",[623],"@MysterionRise",[1574,3052,3053,3055,3056,764,3061,384],{},[271,3054,2393],{}," reported a page and the component it renders as a clone, a JSX element counts as a call now. Reported by ",[619,3057,3060],{"href":3058,"rel":3059},"https:\u002F\u002Fgithub.com\u002FRosenblad",[623],"@Rosenblad",[619,3062,3065],{"href":3063,"rel":3064},"https:\u002F\u002Fgithub.com\u002Fcristianchiriac",[623],"@cristianchiriac",[1574,3067,3068,3069,3072],{},"The VS Code extension couldn't open a clone in a Markdown block, because the reports named it like ",[271,3070,3071],{},"guide.md:markup",". They name the file now.",[1574,3074,3075,3076,3079,3080,3083],{},"Every repository counted the hook samples from ",[271,3077,3078],{},".git\u002Fhooks",", nine bash files and one perl file. jscpd skips ",[271,3081,3082],{},".git"," now.",[263,3085,1709],{"id":1708},[296,3087,3088],{"className":576,"code":1712,"language":578,"meta":301,"style":301},[271,3089,3090,3102,3106],{"__ignoreMap":301},[305,3091,3092,3094,3096,3098,3100],{"class":307,"line":308},[305,3093,1719],{"class":585},[305,3095,1722],{"class":332},[305,3097,1725],{"class":332},[305,3099,1728],{"class":315},[305,3101,1731],{"class":585},[305,3103,3104],{"class":307,"line":341},[305,3105,1736],{"class":597},[305,3107,3108,3110,3112,3114],{"class":307,"line":348},[305,3109,1741],{"class":585},[305,3111,1744],{"class":332},[305,3113,1747],{"class":332},[305,3115,1750],{"class":332},[259,3117,1753,3118,1757,3120,3124],{},[619,3119,1756],{"href":201},[619,3121,1762],{"href":3122,"rel":3123},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Freleases\u002Ftag\u002Fv5.4.2",[623],". Thanks to everyone who sent an issue, a number or a fix for this release!",[1784,3126,3127],{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}",{"title":301,"searchDepth":341,"depth":341,"links":3129},[3130,3131,3132,3133,3134,3135,3136],{"id":1831,"depth":341,"text":1832},{"id":2415,"depth":341,"text":2416},{"id":2637,"depth":341,"text":2638},{"id":2814,"depth":341,"text":2815},{"id":2861,"depth":341,"text":2862},{"id":3001,"depth":341,"text":3002},{"id":1708,"depth":341,"text":1709},"2026-10-20","Boundary rules that keep the code of a module inside it, renamed copies that pair a name with one name, the health score in --history, and Dockerfiles, Makefiles and 73 more formats. With commands and real output.",{},"\u002Fblog\u002Fjscpd-5-4-2","2026-10-20T15:30:00Z",{"title":1812,"description":3143},"jscpd 5.4.2 explained with examples, boundary rules for code that must stay in one module, consistent renaming in --ignore-identifiers and --similarity, health in --history, and built-in file names such as Dockerfile and go.mod.","blog\u002Fjscpd-5-4-2",[1808],"8MYSAGKkx0xxKuoARx1DT4cfb2yyKIvlF0xxv5vURC0",{"id":3148,"title":3149,"authors":3150,"body":3151,"date":4073,"description":4074,"extension":1800,"meta":4075,"navigation":6,"path":4076,"publishedAt":4077,"seo":4078,"stem":4079,"tags":4080,"__hash__":4083},"blog\u002Fblog\u002Fwhen-code-clones-matter.md","How to let a coding agent port your code and know what it ported",[254],{"type":256,"value":3152,"toc":4062},[3153,3168,3171,3178,3188,3195,3201,3204,3207,3211,3239,3245,3250,3253,3259,3304,3307,3368,3372,3375,3437,3451,3455,3461,3484,3501,3504,3508,3517,3541,3544,3564,3567,3570,3574,3577,3592,3595,3602,3605,3609,3612,3618,3632,3642,3645,3651,3662,3670,3673,3676,3741,3747,3752,3763,3766,3772,3777,3789,3793,3796,3853,3859,3881,3884,3906,3910,3979,3982,3985,3989,4007,4053,4059],[259,3154,3155,3156,3161,3162,3167],{},"Agent-made ports are already shipping. Jarred Sumner ",[619,3157,3160],{"href":3158,"rel":3159},"https:\u002F\u002Fbun.com\u002Fblog\u002Fbun-in-rust",[623],"took Bun",", 535,496 lines of Zig without comments, to Rust in 11 days with Claude Code. Stephen Toub ",[619,3163,3166],{"href":3164,"rel":3165},"https:\u002F\u002Fgithub.blog\u002Fai-and-ml\u002Fgenerative-ai\u002Fmigrating-the-github-copilot-runtime-to-rust-using-copilot\u002F",[623],"ported the GitHub Copilot runtime",", about 430,000 lines of production TypeScript, to Rust with Copilot itself. Both write-ups record the agents cutting corners. In the Bun port, Claude read \"let's get all the crates to compile\" as \"stub out the functions with compilation errors\". The Copilot write-up mentions a port that \"omitted SDK callbacks and deleted their end-to-end test\". Toub tracks the port's progress with charts of the production TypeScript left and of the temporary N-API layer between the two languages, which peaked at 2,019 internal exports. The question every such write-up has to answer is how much has really moved, and tests answer a different one. Tests check behavior, and copied code behaves exactly like the code it was copied from, so the shortest path to a green suite is to keep the source.",[259,3169,3170],{},"What I wanted during a port was an answer to the question the tests leave open: how much of the source has really made it into the target, and in what form. The method in this post gives that answer, and it rests on two things, a measurement and a loop.",[259,3172,3173,3174,3177],{},"The measurement comes from ",[271,3175,3176],{},"jscpd --compare",", a feature added in the latest release of the copy-paste detector I maintain. Given two folders, the source and the target, it follows every function of the source into the target and reports where its counterpart turned up, in which file and in which language, and how closely the two match. A counterpart in the target language means the function has been ported; a counterpart in the source language, with the same code, means it has been copied; no counterpart at all means it is still waiting its turn. The tests get the same treatment, so a test that was dropped on the way shows up as a test without a counterpart.",[259,3179,3180,3181,3184,3185,3187],{},"The loop is the ",[271,3182,3183],{},"code-migration"," skill for coding agents, which turns that report into the agent's way of working. The tests go across first. Then the code, one function at a time, beginning with the functions whose dependencies are already in place, and after every step the agent runs ",[271,3186,2389],{}," again to see the new function recognized as a port rather than a copy.",[259,3189,3190],{},[3191,3192],"img",{"alt":3193,"src":3194},"The migration loop","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002F1-migration-loop.svg",[259,3196,3197],{},[3198,3199,3200],"em",{},"The migration loop: the report tells the agent what to port next, and every ported function is measured before the next one.",[259,3202,3203],{},"Neither part cares which languages are involved. jscpd parses 19 of them and pairs functions across any two, and within one language as well, so the same loop serves a move between frameworks. Nor does the direction matter. The source doesn't have to be the old implementation. It can stay in production and keep changing, the target can already hold features the source lacks, and when both stay alive, an iOS and an Android app, say, or a Python library and its TypeScript rewrite, the same report shows their parity.",[259,3205,3206],{},"To see what the loop changes, I gave the same task to the same agent twice, with the skill and without it. The task was to port fs-extra, the Node.js file system library, to Rust. Both ports pass 488 of the 491 tests from fs-extra's own suite and export all 149 names of its API, with the right types. One of them ported 50 of fs-extra's 51 functions, 34 into Rust and 16 into thin JavaScript wrappers over a Rust core. The other copied 32 of them, unchanged, into its own JavaScript layer and wrapped a little Rust around the rest. The tests can't tell these two ports apart. The measurement can, and the second half of this post shows what it found.",[263,3208,3210],{"id":3209},"the-measurement-where-did-each-function-go","The measurement: where did each function go",[259,3212,3213,3214,3217,3218,3221,3222,3225,3226,3229,3230,3221,3232,3234,3235,3238],{},"Most of the time a clone detector looks for copy-paste so you can fold it into one function. A migration flips that. The source is supposed to reappear in the target, only in another language, so duplication, usually something you clean up, becomes the most honest progress report you have. If ",[271,3215,3216],{},"move()"," from ",[271,3219,3220],{},"move.js"," shows up as ",[271,3223,3224],{},"move_impl"," in ",[271,3227,3228],{},"move.rs",", that is progress. If ",[271,3231,3216],{},[271,3233,3216],{}," in the target's ",[271,3236,3237],{},"lib\u002Fmove\u002Fmove.js",", nothing moved.",[259,3240,3241],{},[3191,3242],{"alt":3243,"src":3244},"Where did each function go","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002F2-where-did-each-function-go.svg",[259,3246,3247],{},[3198,3248,3249],{},"Three things the counterpart column can say about one source function. A port and a copy pass the same tests.",[259,3251,3252],{},"A classic token-based detector, which is what jscpd has always been, only sees the second kind, because a JavaScript function and its Rust port share almost no tokens. To see both kinds, you have to compare what functions do rather than how they are spelled.",[259,3254,3255,3256,3258],{},"I looked for something that does this before building it. Cross-language clone detection has been a research field since C2D2 in 2008, with CLCDSA, C4 and SimCL after it, and it produced models and papers rather than a tool you run on two folders. Modernization agents report progress as tasks ticked off a plan they wrote themselves. The closest tool I found keeps a translation ledger the agent fills in. None of them reads two codebases and says, per function and per test, where its counterpart lives. ",[271,3257,2389],{}," does it in five steps.",[296,3260,3262],{"className":576,"code":3261,"language":578,"meta":301,"style":301},"npx jscpd --semantic-download   # once: the CodeRankEmbed model, 548 MB\nnpx jscpd --compare path\u002Fto\u002Fsource path\u002Fto\u002Ftarget --ignore \"**\u002Ftarget\u002F**,**\u002Fnode_modules\u002F**\"\n",[271,3263,3264,3278],{"__ignoreMap":301},[305,3265,3266,3269,3272,3275],{"class":307,"line":308},[305,3267,3268],{"class":585},"npx",[305,3270,3271],{"class":332}," jscpd",[305,3273,3274],{"class":332}," --semantic-download",[305,3276,3277],{"class":597},"   # once: the CodeRankEmbed model, 548 MB\n",[305,3279,3280,3282,3284,3287,3290,3293,3296,3298,3301],{"class":307,"line":341},[305,3281,3268],{"class":585},[305,3283,3271],{"class":332},[305,3285,3286],{"class":332}," --compare",[305,3288,3289],{"class":332}," path\u002Fto\u002Fsource",[305,3291,3292],{"class":332}," path\u002Fto\u002Ftarget",[305,3294,3295],{"class":332}," --ignore",[305,3297,329],{"class":315},[305,3299,3300],{"class":332},"**\u002Ftarget\u002F**,**\u002Fnode_modules\u002F**",[305,3302,3303],{"class":315},"\"\n",[259,3305,3306],{},"The source goes first and the target second. Then:",[3308,3309,3310,3317,3323,3329,3348],"ol",{},[1574,3311,3312,3316],{},[3313,3314,3315],"strong",{},"Find functions."," jscpd parses both folders and extracts every function from 19 languages, Rust and JavaScript among them. Functions under 30 tokens or 5 lines don't count toward the totals, because short functions resemble too many others.",[1574,3318,3319,3322],{},[3313,3320,3321],{},"Embed them."," Each function becomes a vector from CodeRankEmbed, a code embedding model that runs locally inside jscpd. Two functions that do the same job point in the same direction even when language, names and structure differ. The vectors are cached, so the next run only embeds what changed and takes seconds.",[1574,3324,3325,3328],{},[3313,3326,3327],{},"Pair by code."," Two functions pair when each is the other's closest match in the other folder, their cosine similarity clears the model's threshold (0.4125 across languages, 0.6375 within one language), and the match stands out from the runner-up.",[1574,3330,3331,3334,3335,282,3338,3341,3342,3345,3346,384],{},[3313,3332,3333],{},"Pair by name."," A function left over can pair with one of the same name, ignoring case and underscores (",[271,3336,3337],{},"moveSync",[271,3339,3340],{},"move_sync","), if the similarity reaches 0.5625 and both live in modules the first step already linked. This catches short ports without pairing every ",[271,3343,3344],{},"init"," with every other ",[271,3347,3344],{},[1574,3349,3350,3353,3354,776,3357,1619,3360,3363,3364,3367],{},[3313,3351,3352],{},"Report."," Each pair gets a level, ",[271,3355,3356],{},"high",[271,3358,3359],{},"medium",[271,3361,3362],{},"low",", and the report lists what pairs with what, what is left only in the source, and what exists only in the target. Tests are measured separately and only pair with tests. The JSON report also has ",[271,3365,3366],{},"readyToPort",", the unported functions whose callees are all ported already, in the order to take them.",[263,3369,3371],{"id":3370},"reading-the-report","Reading the report",[259,3373,3374],{},"The report has one number at the top, the share of source functions with a counterpart, and a table underneath with the counterpart for each file. Read the table before the number. In a port to another language, a pair whose target is in the source's language with a similarity near 1.00 is a copy, and the headline number counts it as a counterpart. The JSON report has everything needed to count the copies:",[296,3376,3378],{"className":576,"code":3377,"language":578,"meta":301,"style":301},"npx jscpd --compare path\u002Fto\u002Fsource path\u002Fto\u002Ftarget -r json -o report --silent\nnode -e '\nconst r = require(\".\u002Freport\u002Fjscpd-compare.json\")\nconst copies = r.code.pairs.filter(p => !p.b.file.endsWith(\".rs\") && p.similarity >= 0.97)\nconsole.log(new Set(copies.map(p => p.a.file + \":\" + p.a.name)).size, \"functions paired with an unchanged copy\")\n'\n",[271,3379,3380,3407,3417,3422,3427,3432],{"__ignoreMap":301},[305,3381,3382,3384,3386,3388,3390,3392,3395,3398,3401,3404],{"class":307,"line":308},[305,3383,3268],{"class":585},[305,3385,3271],{"class":332},[305,3387,3286],{"class":332},[305,3389,3289],{"class":332},[305,3391,3292],{"class":332},[305,3393,3394],{"class":332}," -r",[305,3396,3397],{"class":332}," json",[305,3399,3400],{"class":332}," -o",[305,3402,3403],{"class":332}," report",[305,3405,3406],{"class":332}," --silent\n",[305,3408,3409,3411,3414],{"class":307,"line":341},[305,3410,586],{"class":585},[305,3412,3413],{"class":332}," -e",[305,3415,3416],{"class":315}," '\n",[305,3418,3419],{"class":307,"line":348},[305,3420,3421],{"class":332},"const r = require(\".\u002Freport\u002Fjscpd-compare.json\")\n",[305,3423,3424],{"class":307,"line":378},[305,3425,3426],{"class":332},"const copies = r.code.pairs.filter(p => !p.b.file.endsWith(\".rs\") && p.similarity >= 0.97)\n",[305,3428,3429],{"class":307,"line":447},[305,3430,3431],{"class":332},"console.log(new Set(copies.map(p => p.a.file + \":\" + p.a.name)).size, \"functions paired with an unchanged copy\")\n",[305,3433,3434],{"class":307,"line":470},[305,3435,3436],{"class":315},"'\n",[259,3438,3439,3440,3443,3444,3447,3448,3450],{},"Change ",[271,3441,3442],{},".rs"," to the extension of your target language. jscpd doesn't flag these pairs on its own yet, and ",[271,3445,3446],{},"--semantic-scope cross",", which keeps only the pairs across languages, doesn't change what ",[271,3449,2389],{}," counts. It would help if it did.",[263,3452,3454],{"id":3453},"the-loop-how-the-skill-drives-a-port","The loop: how the skill drives a port",[259,3456,3457,3458,3460],{},"The report on its own is a measurement. The ",[271,3459,3183],{}," skill makes it the loop the agent works in:",[3308,3462,3463,3469,3472,3475],{},[1574,3464,3465,3466,3468],{},"Run ",[271,3467,2389],{}," on the source and an empty target to list every function to port.",[1574,3470,3471],{},"Collect test coverage of the source and map each test to the functions it runs, so every function is ported together with the tests that check it.",[1574,3473,3474],{},"Port the tests first, keeping inputs and expected values as they are. No stubs to make them compile, because a stub with the source's name can pair by name and count as done.",[1574,3476,3477,3478,3480,3481,3483],{},"Port the code one function at a time, starting from ",[271,3479,3366],{},", and rerun ",[271,3482,2389],{}," after each step to see the function leave the unmatched list and pair with the right thing.",[259,3485,3486,3487,3489,3490,3493,3494,3497,3498,3500],{},"One rule in the skill comes from its first run. The agent vendored its Rust dependencies into the target folder, about two thousand files of tokio, libc and syn, then ran ",[271,3488,2389],{}," without ",[271,3491,3492],{},"--ignore",". jscpd dutifully embedded every function of every crate, and the agent spent 36 minutes waiting on it. The skill now tells the agent to keep vendored code and build output out of both paths, through a ",[271,3495,3496],{},".gitignore"," (which jscpd reads only inside a git repository) or through ",[271,3499,3492],{},". The ban on stubs in step 3 was there from the start, for a similar reason. A stub carries the source's name, pairs by name, and raises the number without moving anything.",[259,3502,3503],{},"Nothing in the four steps names a language. The rest of this post is one project the agent ran them on.",[263,3505,3507],{"id":3506},"the-case-fs-extra-to-rust-twice","The case: fs-extra to Rust, twice",[259,3509,3510,3511,3516],{},"The agent was ",[619,3512,3515],{"href":3513,"rel":3514},"https:\u002F\u002Fgithub.com\u002Fearendil-works\u002Fpi",[623],"pi"," 0.99.1 running GLM-5.3-flash through ollama. The task, word for word in both runs, was to port fs-extra 11.4.1 to Rust as a native addon built with napi-rs, as a drop-in replacement with the same API, behavior and errors. fs-extra's test suite had to pass against the port, the port had to be faster, and the agent had to work without asking questions.",[259,3518,3519,3520,3523,3524,776,3527,282,3530,3533,3534,3537,3538,3540],{},"The two numbers at the top count different things. Of the 149 names fs-extra exports, 104 are Node's own ",[271,3521,3522],{},"fs"," methods passed through, and 45 are fs-extra's own API, which is 27 functions under several names (",[271,3525,3526],{},"mkdirs",[271,3528,3529],{},"mkdirp",[271,3531,3532],{},"ensureDir"," are one function). The 51 are the functions in fs-extra's ",[271,3535,3536],{},"lib\u002F"," folder, internal helpers included, that reach the minimum ",[271,3539,2389],{}," counts, 30 tokens and 5 lines. The folder has 72 in all.",[259,3542,3543],{},"I'll call the two runs by the names their code now has on GitHub:",[1571,3545,3546,3558],{},[1574,3547,3548,3551,3552,282,3554,3557],{},[3313,3549,3550],{},"fs-extra-rs"," got two skills from the jscpd repository, ",[271,3553,3183],{},[271,3555,3556],{},"compare-codebases",", and one extra line in the prompt: \"Use the code-migration skill for this port.\"",[1574,3559,3560,3563],{},[3313,3561,3562],{},"fs-extra-rs-plain"," got nothing extra.",[259,3565,3566],{},"Both ran at the same time on one M1 laptop. This was the second round of the experiment. The first round ended the same way, and I'll come back to it.",[259,3568,3569],{},"fs-extra-rs was done in 123 minutes. fs-extra-rs-plain had its tests green after about an hour and then spent most of the next two running its own benchmark, until it hit the three-hour limit I had set per session.",[263,3571,3573],{"id":3572},"what-the-tests-said","What the tests said",[259,3575,3576],{},"A port that keeps the source's JavaScript is guaranteed to pass the source's tests. It is the one thing about it you can count on.",[259,3578,3579,3580,3583,3584,3587,3588,3591],{},"fs-extra's suite even rewards copying. Six of its test files replace parts of fs-extra's internals with stubs, through proxyquire or a mocked ",[271,3581,3582],{},"fs.rename",", and those tests only work if the JavaScript internals exist. The agent behind fs-extra-rs-plain kept the internals, changed no test, and got 745 passing tests. fs-extra-rs has no JavaScript internals to stub, so its agent rewrote five of those files to cause real failures instead, an ",[271,3585,3586],{},"EACCES"," from a directory with mode ",[271,3589,3590],{},"000"," and real moves between two file systems where the originals mocked one. fs-extra-rs ended with 734 passing and 11 skipped.",[259,3593,3594],{},"Those numbers are each agent's own run of fs-extra's whole suite, 753 tests in 80 files before the agents touched them. Seventeen of those files load fs-extra's private modules directly or through proxyquire, so with the entry point swapped they would still test the original JavaScript. The comparison below counts the other 63 files, 491 tests.",[259,3596,3597,3598,3601],{},"To take the agents' own test changes out of the picture, I also ran fs-extra's unmodified tests against both ports, swapping fs-extra's entry point for the port. Both ports gave the same result, 488 of 491 passing and 2 skipped, and the same single test failed in both, because both export ",[271,3599,3600],{},"fs.realpath.native"," and fs-extra doesn't.",[259,3603,3604],{},"So \"all tests green\" was true for both, and it said nothing about how much porting had happened.",[263,3606,3608],{"id":3607},"what-the-reports-said","What the reports said",[259,3610,3611],{},"Here is part of the report for fs-extra-rs-plain, the port made without the skill:",[296,3613,3616],{"className":3614,"code":3615,"language":2833,"meta":301},[2831]," 80% 41 of 51 functions in fs-extra\u002Flib have a counterpart in fs-extra-rs-plain\n\n  file                     paired  similarity   counterpart\n  ensure\u002Flink.js           2 \u002F 2   1.00         lib\u002Fensure\u002Flink.js\n  ensure\u002Fsymlink-paths.js  2 \u002F 2   1.00         lib\u002Fensure\u002Fsymlink-paths.js\n  move\u002Fmove.js             3 \u002F 3   1.00         lib\u002Fmove\u002Fmove.js\n  move\u002Fmove-sync.js        5 \u002F 5   0.94         lib\u002Fmove\u002Fmove-sync.js\n  util\u002Fstat.js             7 \u002F 7   0.90         lib\u002Futil\u002Fstat.js\n",[271,3617,3615],{"__ignoreMap":301},[259,3619,3620,3621,3623,3624,3626,3627,3631],{},"Look at the counterpart column. ",[271,3622,3220],{}," pairs with ",[271,3625,3237],{}," in the port at a similarity of 1.00, the same function in the same language. That is not a port. It is the original. The ",[619,3628,3630],{"href":3629,"target":671},"\u002Fexamples\u002Fcompare-fs-extra-rs-plain.html","HTML report for fs-extra-rs-plain"," marks these pairs as ported too, and only the file in the counterpart column gives them away.",[3633,3634],"report-screenshot",{":height":3635,":width":3636,"alt":3637,"caption":3638,"dark":3639,"href":3629,"light":3640,"link-text":3641},"1302","1560","The migration map of jscpd --compare for fs-extra-rs-plain, one mark per folder: fs-extra's folders on the left, code as circles and tests as squares, bridged to folders of the same names under lib\u002F in the port on the right; 80% of functions and 428 of 428 tests have a counterpart.","fs-extra-rs-plain, one mark per folder. Circles are code and squares are tests. Most of the code bridges to folders of the same names under lib\u002F, still in JavaScript.","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002Fmap-fs-extra-rs-plain-dark.webp","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002Fmap-fs-extra-rs-plain-light.webp","Open the report for fs-extra-rs-plain",[259,3643,3644],{},"And part of the report for fs-extra-rs:",[296,3646,3649],{"className":3647,"code":3648,"language":2833,"meta":301},[2831]," 98% 50 of 51 functions in fs-extra\u002Flib have a counterpart in fs-extra-rs\n\n  file                     paired   similarity  counterpart\n  copy\u002Fcopy-sync.js        10 \u002F 10  0.83        src\u002Fcopy_sync.rs\n  move\u002Fmove.js             3 \u002F 3    0.85        src\u002Fmove_mod.rs\n  move\u002Fmove-sync.js        5 \u002F 5    0.85        src\u002Fmove_sync.rs\n  util\u002Fstat.js             7 \u002F 7    0.81        src\u002Futil_stat.rs\n",[271,3650,3648],{"__ignoreMap":301},[259,3652,3653,3654,3656,3657,3661],{},"Same files, counterparts in ",[271,3655,3442],{},", similarities around 0.8, which is what a faithful port into another language looks like. Here is ",[619,3658,3660],{"href":3659,"target":671},"\u002Fexamples\u002Fcompare-fs-extra-rs.html","the HTML report for fs-extra-rs",", the port published as @jscpd\u002Ffs-extra.",[3633,3663],{":height":3664,":width":3636,"alt":3665,"caption":3666,"dark":3667,"href":3659,"light":3668,"link-text":3669},"1290","The migration map of jscpd --compare for fs-extra-rs, one mark per folder: fs-extra's code folders bridge to src, the Rust core, and to thin wrappers under lib\u002F, and its test folders bridge to test folders of the same names; 98% of functions and 417 of 428 tests have a counterpart.","fs-extra-rs, one mark per folder. The code bridges to src, the Rust core, and to thin wrappers under lib\u002F.","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002Fmap-fs-extra-rs-dark.webp","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002Fmap-fs-extra-rs-light.webp","Open the report for fs-extra-rs",[259,3671,3672],{},"Both reports come from jscpd 5.4.1 and measure the tests as well as the code. They leave out the ports' benchmarks and build output, and with them the unchanged copy of fs-extra that fs-extra-rs-plain keeps in its benchmark folder.",[259,3674,3675],{},"Sorting all 51 functions by where their counterpart lives:",[3677,3678,3679,3695],"table",{},[3680,3681,3682],"thead",{},[3683,3684,3685,3689,3692],"tr",{},[3686,3687,3688],"th",{},"fs-extra's 51 functions",[3686,3690,3691],{},"fs-extra-rs (with the skill)",[3686,3693,3694],{},"fs-extra-rs-plain (without)",[3696,3697,3698,3710,3721,3732],"tbody",{},[3683,3699,3700,3704,3707],{},[3701,3702,3703],"td",{},"Counterpart in Rust",[3701,3705,3706],{},"34",[3701,3708,3709],{},"4",[3683,3711,3712,3715,3718],{},[3701,3713,3714],{},"Copied unchanged into the port's JavaScript",[3701,3716,3717],{},"0",[3701,3719,3720],{},"32",[3683,3722,3723,3726,3729],{},[3701,3724,3725],{},"Counterpart is a JavaScript wrapper that calls Rust",[3701,3727,3728],{},"16",[3701,3730,3731],{},"5",[3683,3733,3734,3737,3739],{},[3701,3735,3736],{},"No counterpart",[3701,3738,2319],{},[3701,3740,428],{},[259,3742,3743],{},[3191,3744],{"alt":3745,"src":3746},"fs-extra's 51 functions by where their counterpart lives","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002F3-51-functions-by-counterpart.svg",[259,3748,3749],{},[3198,3750,3751],{},"fs-extra's 51 functions by where their counterpart lives. The magenta block is code that never left JavaScript.",[259,3753,3754,3755,3758,3759,3762],{},"The 16 JavaScript pairs in fs-extra-rs are thin files that keep fs-extra's module layout. Each function calls the native core and turns its error into Node's format. Their similarity sits between 0.69 and 0.91, never near 1.00. Its one unpaired function, ",[271,3756,3757],{},"asyncIteratorConcurrentProcess",", has nothing to do in the port, because the Rust ",[271,3760,3761],{},"copy"," walks directories on its own threads. The agent noted that decision rather than writing a stub to raise the number.",[259,3764,3765],{},"In this round the headline numbers point the right way, 98% for fs-extra-rs and 80% for fs-extra-rs-plain. In the first round they didn't. The run without the skill scored 84% and the run with it scored 73%, because the headline number counts a copy as a counterpart, and the copy-heavy port had more counterparts. That run had copied 37 functions. Its own summary called the result \"a drop-in Rust port of fs-extra 11.4.1\" with \"~2,600 lines of Rust\". The copy-counting script above prints 0 and 3 for the runs with the skill, 32 and 37 for the runs without.",[259,3767,3768],{},[3191,3769],{"alt":3770,"src":3771},"Headline percentage against the number of copies","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002F5-headline-vs-copies.svg",[259,3773,3774],{},[3198,3775,3776],{},"The headline number counts a copy as a counterpart. Count the copies before you trust the percentage.",[259,3778,3779,3780,3782,3783,3785,3786,3788],{},"The agent behind fs-extra-rs followed the loop almost to the letter. It ran ",[271,3781,2389],{}," 11 times, and all 11 runs together took under two minutes thanks to the vector cache. It also wrote the ",[271,3784,3496],{}," the skill suggests and never waited on vendored crates. The agent behind fs-extra-rs-plain never ran ",[271,3787,2389],{},", and never had a reason to look at what it had kept.",[263,3790,3792],{"id":3791},"what-the-benchmark-said","What the benchmark said",[259,3794,3795],{},"I benchmarked both ports against the original fs-extra on the same laptop: 30 scenarios, each library in its own process, three rounds with the order rotated, medians with bootstrap confidence intervals.",[3677,3797,3798,3809],{},[3680,3799,3800],{},[3683,3801,3802,3805,3807],{},[3686,3803,3804],{},"30 scenarios",[3686,3806,3691],{},[3686,3808,3694],{},[3696,3810,3811,3822,3832,3842],{},[3683,3812,3813,3816,3819],{},[3701,3814,3815],{},"Faster than fs-extra",[3701,3817,3818],{},"17",[3701,3820,3821],{},"12",[3683,3823,3824,3827,3830],{},[3701,3825,3826],{},"Same speed (the confidence interval includes ×1.00)",[3701,3828,3829],{},"6",[3701,3831,3821],{},[3683,3833,3834,3837,3840],{},[3701,3835,3836],{},"Slower than fs-extra",[3701,3838,3839],{},"7",[3701,3841,3829],{},[3683,3843,3844,3847,3850],{},[3701,3845,3846],{},"Geometric mean speedup, without whole-file copies",[3701,3848,3849],{},"×1.12",[3701,3851,3852],{},"×0.98",[259,3854,3855],{},[3191,3856],{"alt":3857,"src":3858},"30 benchmark scenarios","\u002Fimages\u002Fblog\u002Fwhen-code-clones-matter\u002F4-benchmark-30-scenarios.svg",[259,3860,3861],{},[3198,3862,3863,3864,776,3867,776,3869,776,3872,776,3875,282,3878,384],{},"30 scenarios against the original fs-extra. Six of the twelve ties in the plain port are scenarios that run its copied functions directly: ",[271,3865,3866],{},"move",[271,3868,3337],{},[271,3870,3871],{},"ensureFile",[271,3873,3874],{},"ensureFileSync",[271,3876,3877],{},"ensureSymlinkSync",[271,3879,3880],{},"ensureLinkSync",[259,3882,3883],{},"I leave whole-file copies out of the mean because on macOS both ports hand them to the file system's clone call, and a \"speedup\" of 5 to 260 times is a fact about APFS. The three whole-file copy scenarios are among the faster ones in both columns.",[259,3885,3886,3887,3889,3890,3892,3893,3895,3896,3899,3900,3902,3903,3905],{},"Where fs-extra-rs-plain kept fs-extra's JavaScript, it runs at fs-extra's speed, as the same code should. ",[271,3888,3866],{}," comes out at ×1.00 against ×1.65 in fs-extra-rs, async ",[271,3891,3871],{}," at ×0.99 against ×1.29, ",[271,3894,3877],{}," at ×1.00 against ×1.07. fs-extra-rs isn't faster everywhere, though. Its async ",[271,3897,3898],{},"remove"," is ×0.74 and its async ",[271,3901,3761],{}," of 2,000 small files ×0.87, so a real native port can still lose to Node's own thread pool. The benchmark measures the port; ",[271,3904,2389],{}," tells you whether there is one.",[263,3907,3909],{"id":3908},"what-it-cost","What it cost",[3677,3911,3912,3922],{},[3680,3913,3914],{},[3683,3915,3916,3918,3920],{},[3686,3917],{},[3686,3919,3691],{},[3686,3921,3694],{},[3696,3923,3924,3935,3946,3957,3968],{},[3683,3925,3926,3929,3932],{},[3701,3927,3928],{},"Time",[3701,3930,3931],{},"123 min",[3701,3933,3934],{},"180 min, stopped by the time limit",[3683,3936,3937,3940,3943],{},[3701,3938,3939],{},"Model calls",[3701,3941,3942],{},"503",[3701,3944,3945],{},"342",[3683,3947,3948,3951,3954],{},[3701,3949,3950],{},"Input tokens, not cached",[3701,3952,3953],{},"952 thousand",[3701,3955,3956],{},"2.6 million",[3683,3958,3959,3962,3965],{},[3701,3960,3961],{},"Output tokens",[3701,3963,3964],{},"348 thousand",[3701,3966,3967],{},"350 thousand",[3683,3969,3970,3973,3976],{},[3701,3971,3972],{},"Input tokens read from cache",[3701,3974,3975],{},"141 million",[3701,3977,3978],{},"111 million",[259,3980,3981],{},"I wouldn't read a verdict into these numbers. The run without the skill in the first round took 76 minutes; this one took 180, almost all of the difference in its own benchmark, which ran three times for over 20 minutes each. Each of those pauses outlived the prompt cache, so the next model call read the whole context, about half a million tokens, uncached. That alone accounts for most of fs-extra-rs-plain's uncached input. Between two runs of the same agent with the same prompt, the spread in time was bigger than any effect of the skill.",[259,3983,3984],{},"What the skill reliably changed was the result. In both rounds, the run with it produced a port, and the run without it produced fs-extra with a native addon attached.",[263,3986,3988],{"id":3987},"try-it","Try it",[296,3990,3992],{"className":576,"code":3991,"language":578,"meta":301,"style":301},"npx jscpd --compare path\u002Fto\u002Fsource path\u002Fto\u002Ftarget\n",[271,3993,3994],{"__ignoreMap":301},[305,3995,3996,3998,4000,4002,4004],{"class":307,"line":308},[305,3997,3268],{"class":585},[305,3999,3271],{"class":332},[305,4001,3286],{"class":332},[305,4003,3289],{"class":332},[305,4005,4006],{"class":332}," path\u002Fto\u002Ftarget\n",[1571,4008,4009,4030,4045],{},[1574,4010,4011,4012,4015,4016,1757,4021,4026,4027,4029],{},"The skill installs into any agent that reads skills with one command, ",[271,4013,4014],{},"npx skills add https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd --skill code-migration",", and its full text is on ",[619,4017,4020],{"href":4018,"rel":4019},"https:\u002F\u002Fwww.skills.sh\u002Fkucherenko\u002Fjscpd\u002Fcode-migration",[623],"skills.sh",[619,4022,4025],{"href":4023,"rel":4024},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Ftree\u002Fmaster\u002Fskills",[623],"jscpd repository"," next to ",[271,4028,3556],{},". Then give the agent the single prompt line \"Use the code-migration skill for this port.\"",[1574,4031,4032,4033,4038,4039,4044],{},"The port made with the skill is on npm as ",[619,4034,4037],{"href":4035,"rel":4036},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@jscpd\u002Ffs-extra",[623],"@jscpd\u002Ffs-extra",", with the code at ",[619,4040,4043],{"href":4041,"rel":4042},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Ffs-extra-rs",[623],"kucherenko\u002Ffs-extra-rs",". It is experimental, and only checked as described here.",[1574,4046,4047,4048,384],{},"The port made without the skill is kept for comparison at ",[619,4049,4052],{"href":4050,"rel":4051},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Ffs-extra-rs-plain",[623],"kucherenko\u002Ffs-extra-rs-plain",[259,4054,4055,4056,4058],{},"If you run an agent on a migration, have it run ",[271,4057,2389],{}," after every green test run, and read the counterpart column yourself before you believe the summary. The loop is the same whatever the source and the target are. fs-extra is only the project this agent ran it on.",[1784,4060,4061],{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":301,"searchDepth":341,"depth":341,"links":4063},[4064,4065,4066,4067,4068,4069,4070,4071,4072],{"id":3209,"depth":341,"text":3210},{"id":3370,"depth":341,"text":3371},{"id":3453,"depth":341,"text":3454},{"id":3506,"depth":341,"text":3507},{"id":3572,"depth":341,"text":3573},{"id":3607,"depth":341,"text":3608},{"id":3791,"depth":341,"text":3792},{"id":3908,"depth":341,"text":3909},{"id":3987,"depth":341,"text":3988},"2026-10-12","A method for letting a coding agent port code to another language and checking what it really ported. jscpd --compare follows every source function into the target, the code-migration skill turns the report into a loop, and an fs-extra to Rust experiment shows what the tests miss.",{},"\u002Fblog\u002Fwhen-code-clones-matter","2026-10-12T13:30:00Z",{"title":3149,"description":4074},"blog\u002Fwhen-code-clones-matter",[4081,4082],"migration","compare","49Kie_CDZ8diQwaPPsUqwbz-kGcPsBEKXUVJTuaDw_s",{"id":4085,"title":4086,"authors":4087,"body":4088,"date":4666,"description":4667,"extension":1800,"meta":4668,"navigation":6,"path":4669,"publishedAt":4670,"seo":4671,"stem":4673,"tags":4674,"__hash__":4675},"blog\u002Fblog\u002Fjscpd-5-4.md","What's new in jscpd 5.4 and 5.4.1",[254],{"type":256,"value":4089,"toc":4658},[4090,4102,4106,4112,4115,4118,4163,4177,4210,4213,4261,4272,4279,4347,4352,4356,4373,4384,4425,4445,4449,4462,4465,4471,4483,4487,4493,4499,4520,4522,4604,4606,4636,4655],[259,4091,4092,4093,4095,4096,4098,4099,1828],{},"Two releases in nine days, so one post for both. 5.4.0 added a language server and a way to compare two codebases, 5.4.1 rewrote ",[271,4094,2110],{}," from scratch and added ",[271,4097,2407],{},". Every example below runs on a demo folder from the ",[619,4100,1827],{"href":1825,"rel":4101},[623],[263,4103,4105],{"id":4104},"functions-that-look-alike-in-15-languages","Functions that look alike, in 15 languages",[259,4107,4108,4109,4111],{},"A copied function rarely stays a copy. Someone renames the variables, changes a constant, adds a log line, and the token passes of jscpd lose it, they need a long run of tokens that repeats. ",[271,4110,2110],{}," is for this case. It compares whole functions by the structure of their syntax trees. jscpd normalizes every function first, the names of the functions it calls and its operators stay, local names, field names and literals become markers. Then two functions score the share of subtrees they have in common, 1.0 is the same structure, 0.8 is the default bar.",[259,4113,4114],{},"Up to 5.4.0 this worked for JavaScript and TypeScript only, by the sequence of node types, and the score was loose. Now it reads JavaScript, TypeScript, Python, Java, Kotlin, Scala, C#, Go, Rust, C, C++, PHP, Ruby, Swift and Clojure, plus the code blocks of Markdown files and the scripts of Vue, Svelte and Astro components.",[259,4116,4117],{},"Two Python functions, one prices a parcel, the other prices a policy. Every name and every literal differs, so the default run finds nothing, and the structure is the same:",[296,4119,4121],{"className":576,"code":4120,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Fsimilarity-demo\u002Frenamed\n# Found 0 clones.\njscpd fixtures\u002Fsimilarity-demo\u002Frenamed --similarity\n# Clone found (python, similar (ast) ~1.00)\n#  - insurance.py [1:1 - 8:26] (8 lines, 62 tokens)\n#    shipping.py [1:1 - 8:29]\n# Found 1 clones.\n",[271,4122,4123,4130,4135,4145,4149,4154,4159],{"__ignoreMap":301},[305,4124,4125,4127],{"class":307,"line":308},[305,4126,273],{"class":585},[305,4128,4129],{"class":332}," fixtures\u002Fsimilarity-demo\u002Frenamed\n",[305,4131,4132],{"class":307,"line":341},[305,4133,4134],{"class":597},"# Found 0 clones.\n",[305,4136,4137,4139,4142],{"class":307,"line":348},[305,4138,273],{"class":585},[305,4140,4141],{"class":332}," fixtures\u002Fsimilarity-demo\u002Frenamed",[305,4143,4144],{"class":332}," --similarity\n",[305,4146,4147],{"class":307,"line":378},[305,4148,2783],{"class":597},[305,4150,4151],{"class":307,"line":447},[305,4152,4153],{"class":597},"#  - insurance.py [1:1 - 8:26] (8 lines, 62 tokens)\n",[305,4155,4156],{"class":307,"line":470},[305,4157,4158],{"class":597},"#    shipping.py [1:1 - 8:29]\n",[305,4160,4161],{"class":307,"line":478},[305,4162,1087],{"class":597},[259,4164,4165,4166,2589,4169,4172,4173,4176],{},"An edit costs a few points. ",[271,4167,4168],{},"refunds.ts",[271,4170,4171],{},"orders.ts"," with new names and one ",[271,4174,4175],{},"trace(refund.id)"," call added inside the loop, the pair scores 0.85:",[296,4178,4180],{"className":576,"code":4179,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Fsimilarity-demo\u002Fedited --similarity\n# Clone found (typescript, similar (ast) ~0.85)\n#  - orders.ts [1:8 - 14:2] (14 lines, 121 tokens)\n#    refunds.ts [1:8 - 15:2]\n# Found 1 clones.\n",[271,4181,4182,4191,4196,4201,4206],{"__ignoreMap":301},[305,4183,4184,4186,4189],{"class":307,"line":308},[305,4185,273],{"class":585},[305,4187,4188],{"class":332}," fixtures\u002Fsimilarity-demo\u002Fedited",[305,4190,4144],{"class":332},[305,4192,4193],{"class":307,"line":341},[305,4194,4195],{"class":597},"# Clone found (typescript, similar (ast) ~0.85)\n",[305,4197,4198],{"class":307,"line":348},[305,4199,4200],{"class":597},"#  - orders.ts [1:8 - 14:2] (14 lines, 121 tokens)\n",[305,4202,4203],{"class":307,"line":378},[305,4204,4205],{"class":597},"#    refunds.ts [1:8 - 15:2]\n",[305,4207,4208],{"class":307,"line":447},[305,4209,1087],{"class":597},[259,4211,4212],{},"Called names count. Two functions with the same shape of statements that call different methods score 0.66, under the default, and show up only when you ask for 0.6:",[296,4214,4216],{"className":576,"code":4215,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Fsimilarity-demo\u002Fcalls --similarity\n# Found 0 clones.\njscpd fixtures\u002Fsimilarity-demo\u002Fcalls --similarity 0.6\n# Clone found (python, similar (ast) ~0.66)\n#  - accounts.py [1:1 - 8:19] (8 lines, 62 tokens)\n#    devices.py [1:1 - 8:18]\n# Found 1 clones.\n",[271,4217,4218,4227,4231,4242,4247,4252,4257],{"__ignoreMap":301},[305,4219,4220,4222,4225],{"class":307,"line":308},[305,4221,273],{"class":585},[305,4223,4224],{"class":332}," fixtures\u002Fsimilarity-demo\u002Fcalls",[305,4226,4144],{"class":332},[305,4228,4229],{"class":307,"line":341},[305,4230,4134],{"class":597},[305,4232,4233,4235,4237,4239],{"class":307,"line":348},[305,4234,273],{"class":585},[305,4236,4224],{"class":332},[305,4238,2760],{"class":332},[305,4240,4241],{"class":390}," 0.6\n",[305,4243,4244],{"class":307,"line":378},[305,4245,4246],{"class":597},"# Clone found (python, similar (ast) ~0.66)\n",[305,4248,4249],{"class":307,"line":447},[305,4250,4251],{"class":597},"#  - accounts.py [1:1 - 8:19] (8 lines, 62 tokens)\n",[305,4253,4254],{"class":307,"line":470},[305,4255,4256],{"class":597},"#    devices.py [1:1 - 8:18]\n",[305,4258,4259],{"class":307,"line":478},[305,4260,1087],{"class":597},[259,4262,4263,4264,4267,4268,4271],{},"The search is exact, it finds every pair at or above the ratio. An index of the fingerprints spares it comparing every function with every other one. On 100 open-source repositories it found the same 58,405 pairs as a brute-force run of the same method, in 65 seconds on one thread, the brute-force run took 498. Test files stay out, ",[271,4265,4266],{},"--min-nodes"," (20 by default) skips the tiny functions, and ",[271,4269,4270],{},"--similarity 1"," reports the functions with exactly the same structure.",[259,4273,4274,4275,4278],{},"Two things to know after the update. The scores differ from 5.4.0, so a threshold or a baseline set on the old scores needs a refresh. And there is a new reporter, ",[271,4276,4277],{},"-r edn",", which writes every pair with its score and the size of both trees, most similar first:",[296,4280,4282],{"className":576,"code":4281,"language":578,"meta":301,"style":301},"jscpd fixtures\u002Fsimilarity-demo\u002Frenamed --similarity -r edn -o report\n# {:candidates [\n#  {:score 1.0\n#   :language \"python\"\n#   :left {:file \"insurance.py\", :start-line 1, :end-line 8}\n#   :right {:file \"shipping.py\", :start-line 1, :end-line 8}\n#   :left-nodes 112\n#   :right-nodes 112}\n# ]\n#  :clones []}\n",[271,4283,4284,4302,4307,4312,4317,4322,4327,4332,4337,4342],{"__ignoreMap":301},[305,4285,4286,4288,4290,4292,4294,4297,4299],{"class":307,"line":308},[305,4287,273],{"class":585},[305,4289,4141],{"class":332},[305,4291,2760],{"class":332},[305,4293,3394],{"class":332},[305,4295,4296],{"class":332}," edn",[305,4298,3400],{"class":332},[305,4300,4301],{"class":332}," report\n",[305,4303,4304],{"class":307,"line":341},[305,4305,4306],{"class":597},"# {:candidates [\n",[305,4308,4309],{"class":307,"line":348},[305,4310,4311],{"class":597},"#  {:score 1.0\n",[305,4313,4314],{"class":307,"line":378},[305,4315,4316],{"class":597},"#   :language \"python\"\n",[305,4318,4319],{"class":307,"line":447},[305,4320,4321],{"class":597},"#   :left {:file \"insurance.py\", :start-line 1, :end-line 8}\n",[305,4323,4324],{"class":307,"line":470},[305,4325,4326],{"class":597},"#   :right {:file \"shipping.py\", :start-line 1, :end-line 8}\n",[305,4328,4329],{"class":307,"line":478},[305,4330,4331],{"class":597},"#   :left-nodes 112\n",[305,4333,4334],{"class":307,"line":499},[305,4335,4336],{"class":597},"#   :right-nodes 112}\n",[305,4338,4339],{"class":307,"line":526},[305,4340,4341],{"class":597},"# ]\n",[305,4343,4344],{"class":307,"line":546},[305,4345,4346],{"class":597},"#  :clones []}\n",[259,4348,4349,4350,384],{},"The guide has the whole method, with a table of what one edit does to the score - ",[619,4351,95],{"href":96},[263,4353,4355],{"id":4354},"only-the-clones-of-the-files-you-changed","Only the clones of the files you changed",[259,4357,4358,4360,4361,4364,4365,4368,4369,4372],{},[271,4359,2407],{}," takes the changed files from ",[271,4362,4363],{},"git status",", scans everything, and reports a clone when one of its fragments is in a changed file. The first run saves the clones of HEAD to ",[271,4366,4367],{},".jscpd-baseline.json",", and a clone HEAD did not have is marked ",[271,4370,4371],{},"[NEW]",". After a commit the baseline is built again on its own.",[259,4374,4375,4376,4379,4380,4383],{},"In a repository where ",[271,4377,4378],{},"queue.js"," is unchanged and a new ",[271,4381,4382],{},"ring.js"," copies its class:",[296,4385,4387],{"className":576,"code":4386,"language":578,"meta":301,"style":301},"jscpd --changed src --no-colors --no-tips\n# Clone found (javascript) [NEW]\n#  - queue.js [1:20 - 17:2] (17 lines, 112 tokens)\n#    ring.js [1:19 - 17:2]\n# Found 1 clones (1 new).\n",[271,4388,4389,4405,4410,4415,4420],{"__ignoreMap":301},[305,4390,4391,4393,4396,4399,4402],{"class":307,"line":308},[305,4392,273],{"class":585},[305,4394,4395],{"class":332}," --changed",[305,4397,4398],{"class":332}," src",[305,4400,4401],{"class":332}," --no-colors",[305,4403,4404],{"class":332}," --no-tips\n",[305,4406,4407],{"class":307,"line":341},[305,4408,4409],{"class":597},"# Clone found (javascript) [NEW]\n",[305,4411,4412],{"class":307,"line":348},[305,4413,4414],{"class":597},"#  - queue.js [1:20 - 17:2] (17 lines, 112 tokens)\n",[305,4416,4417],{"class":307,"line":378},[305,4418,4419],{"class":597},"#    ring.js [1:19 - 17:2]\n",[305,4421,4422],{"class":307,"line":447},[305,4423,4424],{"class":597},"# Found 1 clones (1 new).\n",[259,4426,4427,4428,4431,4432,4435,4436,4439,4440,384],{},"With ",[271,4429,4430],{},"--fail-on-new-clones 0"," this is a pre-commit gate that fails on the clone you are about to add and keeps quiet about the old ones. ",[271,4433,4434],{},"--changed-only"," scans the changed files alone, it is faster and sees only the clones between them. The hook setup is in the ",[619,4437,4438],{"href":41},"pre-commit guide",", and the demo repository is built step by step in ",[619,4441,4444],{"href":4442,"rel":4443},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Ftree\u002Fmaster\u002Ffixtures\u002Fchanged-demo",[623],"fixtures\u002Fchanged-demo",[263,4446,4448],{"id":4447},"jscpd-in-the-editor","jscpd in the editor",[259,4450,4451,4454,4455,4458,4459,4461],{},[271,4452,4453],{},"jscpd --lsp"," starts jscpd as a language server. The editor sends the text as you type, after 300 ms of quiet the server tokenizes the file again from the buffer and searches its pool, and the findings come back as diagnostics that follow the text, saved or not. Clones are on by default, similar functions, semantic clones, dead code and complexity are switched on in the ",[271,4456,4457],{},"lsp"," section of ",[271,4460,1841],{}," or from the editor settings.",[259,4463,4464],{},"This is what the demo project publishes for one file, printed through headless Neovim:",[296,4466,4469],{"className":4467,"code":4468,"language":2833,"meta":301},[2831],"4 jscpd\u002Fduplicate-code Duplicated in src\u002Fholds.js:4-13 (80 tokens)\n13 jscpd\u002Fsimilar-function Same structure as the function at src\u002Fholds.js:13-20 (1.00)\n22 jscpd\u002Fcomplex-function Complexity 20 in loanStatus, over the limit of 15\n",[271,4470,4468],{"__ignoreMap":301},[259,4472,4473,4474,282,4477,4479,4480,384],{},"A clone comes with two code actions, go to the other copy, and ignore this clone, which wraps the fragment in ",[271,4475,4476],{},"jscpd:ignore-start",[271,4478,1104],{},". There is a VS Code extension and a JetBrains plugin, both start the server for you and offer to download the binary when it is not on the PATH. Neovim, Helix, Sublime Text and Emacs need a few lines of config, they are in the ",[619,4481,4482],{"href":66},"editors guide",[263,4484,4486],{"id":4485},"how-far-a-port-has-come","How far a port has come",[259,4488,4489,4492],{},[271,4490,4491],{},"jscpd --compare source target"," is for a port from one language to another, or for two implementations of one app. It pairs the functions of two folders with the semantic model and reports which functions of each side have a counterpart on the other. The demo is a billing module halfway through a port from Python to TypeScript:",[296,4494,4497],{"className":4495,"code":4496,"language":2833,"meta":301},[2831],"Code\n 71% 5 of 7 functions in python have a counterpart in typescript\n 80% 4 of 5 functions in typescript have a counterpart in python\n\nPaired under other names (1):\n  python                        typescript              similarity\n  billing.py:28 tax_for_region  billing.ts:27 salesTax  0.87 high\n\nOnly in python (2):\n  billing.py (1)\n    46  due_date                6 lines\n  shipping.py (1)\n    18  estimate_delivery_days  8 lines\n\nOnly in typescript (1):\n  billing.ts (1)\n    39  toCurrency  8 lines\n",[271,4498,4496],{"__ignoreMap":301},[259,4500,4501,4502,4505,4506,4508,4509,282,4511,776,4513,4516,4517,384],{},"Tests and code are measured apart, a test pairs only with a test. ",[271,4503,4504],{},"-r html"," draws both sides as dependency graphs with the pairs bridging them. It needs the embedding model, ",[271,4507,2396],{}," gets it once, 548 MB. It is experimental. On the Java and Python versions of QR-Code-generator it paired 30 of 41 Java functions with no wrong pair. Two agent skills go with it, ",[271,4510,3556],{},[271,4512,3183],{},[271,4514,4515],{},"npx skills add kucherenko\u002Fjscpd --skill code-migration"," installs one. The details are in the ",[619,4518,4519],{"href":86},"compare guide",[263,4521,3002],{"id":3001},[1571,4523,4524,4539,4553,4563,4585,4601],{},[1574,4525,4526,4529,4530,4533,4534,384],{},[271,4527,4528],{},"--report-name"," sets the base name of the report files, so two runs into one folder no longer overwrite each other, and the GitHub Action takes it as ",[271,4531,4532],{},"report-name",". Thank you ",[619,4535,4538],{"href":4536,"rel":4537},"https:\u002F\u002Fgithub.com\u002FMannXo",[623],"@MannXo",[1574,4540,4541,4542,4545,4546,4549,4550,384],{},"The MCP server takes ",[271,4543,4544],{},"kinds"," in every tool and has ",[271,4547,4548],{},"compare_folders",", see the ",[619,4551,4552],{"href":61},"agents guide",[1574,4554,4555,4556,4558,4559,4562],{},"Pairs from ",[271,4557,2110],{}," have a SARIF rule of their own, ",[271,4560,4561],{},"jscpd\u002Fsimilar-function",". GitHub code scanning matches alerts by rule, so the first upload after the update closes the old alerts and opens the same findings under the new rule.",[1574,4564,4565,282,4567,4569,4570,4572,4573,4576,4577,764,4580,384],{},[271,4566,2393],{},[271,4568,2389],{}," found functions named ",[271,4571,481],{}," in C, C++ and C#, a branch after ",[271,4574,4575],{},"#if"," was read as a function. Reported by ",[619,4578,3050],{"href":3048,"rel":4579},[623],[619,4581,4584],{"href":4582,"rel":4583},"https:\u002F\u002Fgithub.com\u002Fmvanhorn",[623],"@mvanhorn",[1574,4586,4587,4590,4591,4594,4595,4600],{},[271,4588,4589],{},"--dead-code"," reported an import used only in a TSDoc ",[271,4592,4593],{},"{@link}"," as unused. The readers of a ",[619,4596,4599],{"href":4597,"rel":4598},"https:\u002F\u002Fdou.ua\u002Fforums\u002Ftopic\u002F62369\u002F",[623],"DOU.ua thread"," caught it.",[1574,4602,4603],{},"git commands run from a hook acted on the hook's repository, that is fixed, and an API key echoed in an embeddings error is redacted now.",[263,4605,1709],{"id":1708},[296,4607,4608],{"className":576,"code":1712,"language":578,"meta":301,"style":301},[271,4609,4610,4622,4626],{"__ignoreMap":301},[305,4611,4612,4614,4616,4618,4620],{"class":307,"line":308},[305,4613,1719],{"class":585},[305,4615,1722],{"class":332},[305,4617,1725],{"class":332},[305,4619,1728],{"class":315},[305,4621,1731],{"class":585},[305,4623,4624],{"class":307,"line":341},[305,4625,1736],{"class":597},[305,4627,4628,4630,4632,4634],{"class":307,"line":348},[305,4629,1741],{"class":585},[305,4631,1744],{"class":332},[305,4633,1747],{"class":332},[305,4635,1750],{"class":332},[259,4637,1753,4638,4640,4641,4644,4645,4647,4648,4651,4652,4654],{},[619,4639,1756],{"href":201},". Most of 5.4.1 started as issues from ",[619,4642,2989],{"href":2987,"rel":4643},[623],", the structural ",[271,4646,2110],{},", the ",[271,4649,4650],{},"edn"," reporter and ",[271,4653,2407],{}," are his ideas. Thank you!",[1784,4656,4657],{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}",{"title":301,"searchDepth":341,"depth":341,"links":4659},[4660,4661,4662,4663,4664,4665],{"id":4104,"depth":341,"text":4105},{"id":4354,"depth":341,"text":4355},{"id":4447,"depth":341,"text":4448},{"id":4485,"depth":341,"text":4486},{"id":3001,"depth":341,"text":3002},{"id":1708,"depth":341,"text":1709},"2026-10-11","Similar functions by structure in 15 languages, clones of the files you are changing, jscpd inside the editor, and a progress number for a port. With commands and real output.",{},"\u002Fblog\u002Fjscpd-5-4","2026-10-11T12:00:00Z",{"title":4086,"description":4672},"jscpd 5.4.0 and 5.4.1 explained with examples, similar functions in 15 languages, --changed, the language server, --compare and the edn reporter.","blog\u002Fjscpd-5-4",[1808],"LJk4kynuJD9_12XjgNb358NdUe7XLOM25hLKiK1QsTM",{"\u002Fblog\u002Fjscpd-5-4-3":4677,"\u002Fblog\u002Fjscpd-5-4-2":4678,"\u002Fblog\u002Fwhen-code-clones-matter":4681,"\u002Fblog\u002Fjscpd-5-4":4684},{"views":378,"visits":308},{"views":4679,"visits":4680},67,62,{"views":4682,"visits":4683},522,128,{"views":4680,"visits":4685},41,1795510246710]