[{"data":1,"prerenderedAt":779},["ShallowReactive",2],{"navigation_docs":3,"-start-quickstart":239,"-start-quickstart-surround":774},[4,29,94,114,184],{"title":5,"icon":6,"path":7,"stem":8,"children":9},"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],{"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,"icon":6,"path":96,"stem":97,"children":98,"page":6},"Concepts","\u002Fconcepts","3.concepts",[99,104,109],{"title":100,"path":101,"stem":102,"icon":103},"Types of code clones","\u002Fconcepts\u002Fclone-types","3.concepts\u002F1.clone-types","i-lucide-copy",{"title":105,"path":106,"stem":107,"icon":108},"How detection works","\u002Fconcepts\u002Fhow-detection-works","3.concepts\u002F2.how-detection-works","i-lucide-scan-search",{"title":110,"path":111,"stem":112,"icon":113},"The health score","\u002Fconcepts\u002Fhealth-score","3.concepts\u002F3.health-score","i-lucide-heart-pulse",{"title":115,"icon":6,"path":116,"stem":117,"children":118,"page":6},"Reference","\u002Freference","4.reference",[119,124,129,134,171,176,180],{"title":120,"path":121,"stem":122,"icon":123},"CLI options","\u002Freference\u002Fcli","4.reference\u002F1.cli","i-lucide-terminal",{"title":125,"path":126,"stem":127,"icon":128},"The config file","\u002Freference\u002Fconfig-file","4.reference\u002F2.config-file","i-lucide-settings",{"title":130,"path":131,"stem":132,"icon":133},"Exit codes","\u002Freference\u002Fexit-codes","4.reference\u002F3.exit-codes","i-lucide-log-out",{"title":135,"icon":6,"path":136,"stem":137,"children":138},"Reporters","\u002Freference\u002Freporters","4.reference\u002F4.reporters\u002Findex",[139,141,146,151,156,161,166],{"title":135,"path":136,"stem":137,"icon":140},"i-lucide-file-chart-column",{"title":142,"path":143,"stem":144,"icon":145},"HTML reporter","\u002Freference\u002Freporters\u002Fhtml","4.reference\u002F4.reporters\u002F2.html","i-lucide-file-code",{"title":147,"path":148,"stem":149,"icon":150},"JSON reporter","\u002Freference\u002Freporters\u002Fjson","4.reference\u002F4.reporters\u002F3.json","i-lucide-braces",{"title":152,"path":153,"stem":154,"icon":155},"Badge reporter","\u002Freference\u002Freporters\u002Fbadge","4.reference\u002F4.reporters\u002F4.badge","i-lucide-award",{"title":157,"path":158,"stem":159,"icon":160},"SARIF reporter","\u002Freference\u002Freporters\u002Fsarif","4.reference\u002F4.reporters\u002F5.sarif","i-lucide-shield-check",{"title":162,"path":163,"stem":164,"icon":165},"CodeClimate reporter","\u002Freference\u002Freporters\u002Fcodeclimate","4.reference\u002F4.reporters\u002F6.codeclimate","i-lucide-flag-triangle-right",{"title":167,"path":168,"stem":169,"icon":170},"OpenMetrics reporter","\u002Freference\u002Freporters\u002Fopenmetrics","4.reference\u002F4.reporters\u002F7.openmetrics","i-lucide-activity",{"title":172,"path":173,"stem":174,"icon":175},"Supported formats","\u002Freference\u002Fsupported-formats","4.reference\u002F5.supported-formats","i-lucide-languages",{"title":177,"path":178,"stem":179,"icon":38},"GitHub Action","\u002Freference\u002Fgithub-action","4.reference\u002F6.github-action",{"title":181,"path":182,"stem":183,"icon":68},"Rust crates","\u002Freference\u002Frust-crates","4.reference\u002F7.rust-crates",{"title":185,"icon":6,"path":186,"stem":187,"children":188,"page":6},"Project","\u002Fproject","5.project",[189,194,199,204,229,234],{"title":190,"path":191,"stem":192,"icon":193},"Changelog","\u002Fproject\u002Fchangelog","5.project\u002F1.changelog","i-lucide-scroll-text",{"title":195,"path":196,"stem":197,"icon":198},"Migrating from v4 to v5","\u002Fproject\u002Fmigration","5.project\u002F2.migration","i-lucide-arrow-right-left",{"title":200,"path":201,"stem":202,"icon":203},"jscpd v4 (TypeScript)","\u002Fproject\u002Fv4","5.project\u002F3.v4","i-simple-icons-typescript",{"title":205,"icon":6,"path":206,"stem":207,"children":208},"Benchmarks","\u002Fproject\u002Fbenchmarks","5.project\u002F4.benchmarks\u002Findex",[209,211,216,220,225],{"title":205,"path":206,"stem":207,"icon":210},"i-lucide-gauge",{"title":212,"path":213,"stem":214,"icon":215},"Detection Speed","\u002Fproject\u002Fbenchmarks\u002Fdetection-speed","5.project\u002F4.benchmarks\u002F2.detection-speed","i-lucide-zap",{"title":217,"path":218,"stem":219,"icon":58},"Multi-Format Detection","\u002Fproject\u002Fbenchmarks\u002Fcross-format","5.project\u002F4.benchmarks\u002F3.cross-format",{"title":221,"path":222,"stem":223,"icon":224},"AI Token Efficiency","\u002Fproject\u002Fbenchmarks\u002Fai-token-efficiency","5.project\u002F4.benchmarks\u002F4.ai-token-efficiency","i-lucide-sparkles",{"title":226,"path":227,"stem":228,"icon":93},"Embedding Models","\u002Fproject\u002Fbenchmarks\u002Fembedding-models","5.project\u002F4.benchmarks\u002F5.embedding-models",{"title":230,"path":231,"stem":232,"icon":233},"Research","\u002Fproject\u002Fresearch","5.project\u002F5.research","i-lucide-graduation-cap",{"title":235,"path":236,"stem":237,"icon":238},"Articles","\u002Fproject\u002Farticles","5.project\u002F6.articles","i-lucide-newspaper",{"id":240,"title":20,"body":241,"description":767,"extension":768,"links":769,"meta":770,"navigation":771,"path":21,"seo":772,"stem":22,"__hash__":773},"docs\u002F1.start\u002F3.quickstart.md",{"type":242,"value":243,"toc":759},"minimark",[244,253,258,278,282,333,341,347,351,358,371,377,380,468,486,490,496,525,531,537,541,559,686,701,705,755],[245,246,247,248,252],"p",{},"At the end of this page you have scanned your own repository, you know how to read what jscpd prints, and the scan fails your build when duplication grows. Every output below comes from ",[249,250,251],"code",{},"fixtures\u002Fmcp-demo"," in the jscpd repository, a small JavaScript project with three copied blocks; yours will show your files.",[254,255,257],"h2",{"id":256},"before-you-start","Before you start",[245,259,260,261,264,265,268,269,272,273,277],{},"One of these on the machine: a POSIX shell with ",[249,262,263],{},"curl"," (macOS, Linux), Node.js 18 or newer, Python with ",[249,266,267],{},"pip",", or Rust with ",[249,270,271],{},"cargo",". Windows users take the PowerShell installer from the ",[274,275,276],"a",{"href":16},"installation page",".",[254,279,281],{"id":280},"_1-install","1. Install",[283,284,290],"pre",{"className":285,"code":286,"filename":287,"language":288,"meta":289,"style":289},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl -fsSL https:\u002F\u002Fjscpd.dev\u002Finstall.sh | bash   # macOS and Linux: one binary, no runtime\nnpx jscpd --version                               # or no install at all, with Node.js\n","Terminal","bash","",[249,291,292,318],{"__ignoreMap":289},[293,294,297,300,304,307,311,314],"span",{"class":295,"line":296},"line",1,[293,298,263],{"class":299},"sBMFI",[293,301,303],{"class":302},"sfazB"," -fsSL",[293,305,306],{"class":302}," https:\u002F\u002Fjscpd.dev\u002Finstall.sh",[293,308,310],{"class":309},"sMK4o"," |",[293,312,313],{"class":299}," bash",[293,315,317],{"class":316},"sHwdD","   # macOS and Linux: one binary, no runtime\n",[293,319,321,324,327,330],{"class":295,"line":320},2,[293,322,323],{"class":299},"npx",[293,325,326],{"class":302}," jscpd",[293,328,329],{"class":302}," --version",[293,331,332],{"class":316},"                               # or no install at all, with Node.js\n",[283,334,339],{"className":335,"code":337,"language":338,"meta":289},[336],"language-text","jscpd 5.4.0\n","text",[249,340,337],{"__ignoreMap":289},[245,342,343,344,346],{},"The ",[274,345,276],{"href":16}," lists npm, pip, cargo, Homebrew, nix and Docker.",[254,348,350],{"id":349},"_2-scan","2. Scan",[245,352,353,354,357],{},"Run jscpd in the directory you want to scan. Without options it reports exact copies of at least 5 lines and 50 tokens, skips whatever ",[249,355,356],{},".gitignore"," skips, and prints the clones followed by a table per format.",[283,359,361],{"className":285,"code":360,"filename":287,"language":288,"meta":289,"style":289},"jscpd .\n",[249,362,363],{"__ignoreMap":289},[293,364,365,368],{"class":295,"line":296},[293,366,367],{"class":299},"jscpd",[293,369,370],{"class":302}," .\n",[283,372,375],{"className":373,"code":374,"language":338,"meta":289},[336],"Clone found (javascript)\n - src\u002Finvoice.js [1:1 - 6:72] (6 lines, 105 tokens)\n   src\u002Fprint\u002Finvoice.js [1:1 - 6:72]\nClone found (javascript)\n - src\u002Finvoice.js [6:71 - 12:2] (7 lines, 93 tokens)\n   src\u002Fprint\u002Finvoice.js [7:53 - 13:2]\nClone found (javascript)\n - src\u002Forders.js [1:1 - 12:2] (12 lines, 124 tokens)\n   src\u002Freports\u002Forders.js [1:1 - 12:2]\nFound 3 clones.\n",[249,376,374],{"__ignoreMap":289},[245,378,379],{},"After the clones, the terminal prints one row per format and a total:",[381,382,383,406],"table",{},[384,385,386],"thead",{},[387,388,389,393,397,400,403],"tr",{},[390,391,392],"th",{},"Format",[390,394,396],{"align":395},"right","Files analyzed",[390,398,399],{"align":395},"Lines",[390,401,402],{"align":395},"Clones",[390,404,405],{"align":395},"Duplicated lines",[407,408,409,429,452],"tbody",{},[387,410,411,417,420,423,426],{},[412,413,414],"td",{},[249,415,416],{},"javascript",[412,418,419],{"align":395},"6",[412,421,422],{"align":395},"69",[412,424,425],{"align":395},"3",[412,427,428],{"align":395},"25 (36.23 %)",[387,430,431,442,444,447,450],{},[412,432,433,435,436,435,439],{},[249,434,288],{},", ",[249,437,438],{},"markdown",[249,440,441],{},"python",[412,443,425],{"align":395},[412,445,446],{"align":395},"123",[412,448,449],{"align":395},"0",[412,451,449],{"align":395},[387,453,454,457,460,463,465],{},[412,455,456],{},"Total",[412,458,459],{"align":395},"9",[412,461,462],{"align":395},"192",[412,464,425],{"align":395},[412,466,467],{"align":395},"25 (13.02 %)",[245,469,470,471,474,475,478,479,485],{},"Each clone names its two places as ",[249,472,473],{},"file [line:column - line:column]"," and says how long the shared block is. The percentage is duplication: duplicated lines over all lines, per format and in total. Here it is 13.02 % of 192 lines, and the ",[249,476,477],{},"invoice.js"," pair appears twice because one inserted line splits it; ",[274,480,482],{"href":481},"\u002Fconcepts\u002Fclone-types#type-3-near-miss-clones",[249,483,484],{},"--max-gap-lines"," joins the halves.",[254,487,489],{"id":488},"_3-make-it-fail","3. Make it fail",[245,491,492,495],{},[249,493,494],{},"--threshold"," is the ceiling in percent. When the total duplication is above it, jscpd prints an error after the report and exits with code 1, which fails a pre-commit hook or a CI job.",[283,497,499],{"className":285,"code":498,"filename":287,"language":288,"meta":289,"style":289},"jscpd . --threshold 1\necho $?\n",[249,500,501,515],{"__ignoreMap":289},[293,502,503,505,508,511],{"class":295,"line":296},[293,504,367],{"class":299},[293,506,507],{"class":302}," .",[293,509,510],{"class":302}," --threshold",[293,512,514],{"class":513},"sbssI"," 1\n",[293,516,517,521],{"class":295,"line":320},[293,518,520],{"class":519},"s2Zo4","echo",[293,522,524],{"class":523},"sTEyZ"," $?\n",[283,526,529],{"className":527,"code":528,"language":338,"meta":289},[336],"Found 3 clones.\nERROR: jscpd found too many duplicates (13.0%) over threshold (1.0%)\n1\n",[249,530,528],{"__ignoreMap":289},[245,532,533,534,277],{},"Pick a value a little above where the project stands today, so the build stays green until someone adds duplication. To fail only on clones that are new since a known state, use a ",[274,535,536],{"href":46},"baseline",[254,538,540],{"id":539},"_4-save-the-settings","4. Save the settings",[245,542,543,544,547,548,551,552,554,555,558],{},"jscpd reads ",[249,545,546],{},".jscpd.json"," from the directory it runs in (not from the scanned path), then ",[249,549,550],{},".config\u002Fjscpd.json",", then the ",[249,553,367],{}," key of ",[249,556,557],{},"package.json"," there. Keys are the flags in camelCase; a flag on the command line wins over the file.",[283,560,564],{"className":561,"code":562,"filename":546,"language":563,"meta":289,"style":289},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"threshold\": 3,\n  \"ignore\": [\"**\u002Fnode_modules\u002F**\", \"**\u002Fdist\u002F**\"],\n  \"reporters\": [\"console\", \"html\"],\n  \"output\": \"report\"\n}\n","json",[249,565,566,571,592,628,660,680],{"__ignoreMap":289},[293,567,568],{"class":295,"line":296},[293,569,570],{"class":309},"{\n",[293,572,573,576,580,583,586,589],{"class":295,"line":320},[293,574,575],{"class":309},"  \"",[293,577,579],{"class":578},"spNyl","threshold",[293,581,582],{"class":309},"\"",[293,584,585],{"class":309},":",[293,587,588],{"class":513}," 3",[293,590,591],{"class":309},",\n",[293,593,595,597,600,602,604,607,609,612,614,617,620,623,625],{"class":295,"line":594},3,[293,596,575],{"class":309},[293,598,599],{"class":578},"ignore",[293,601,582],{"class":309},[293,603,585],{"class":309},[293,605,606],{"class":309}," [",[293,608,582],{"class":309},[293,610,611],{"class":302},"**\u002Fnode_modules\u002F**",[293,613,582],{"class":309},[293,615,616],{"class":309},",",[293,618,619],{"class":309}," \"",[293,621,622],{"class":302},"**\u002Fdist\u002F**",[293,624,582],{"class":309},[293,626,627],{"class":309},"],\n",[293,629,631,633,636,638,640,642,644,647,649,651,653,656,658],{"class":295,"line":630},4,[293,632,575],{"class":309},[293,634,635],{"class":578},"reporters",[293,637,582],{"class":309},[293,639,585],{"class":309},[293,641,606],{"class":309},[293,643,582],{"class":309},[293,645,646],{"class":302},"console",[293,648,582],{"class":309},[293,650,616],{"class":309},[293,652,619],{"class":309},[293,654,655],{"class":302},"html",[293,657,582],{"class":309},[293,659,627],{"class":309},[293,661,663,665,668,670,672,674,677],{"class":295,"line":662},5,[293,664,575],{"class":309},[293,666,667],{"class":578},"output",[293,669,582],{"class":309},[293,671,585],{"class":309},[293,673,619],{"class":309},[293,675,676],{"class":302},"report",[293,678,679],{"class":309},"\"\n",[293,681,683],{"class":295,"line":682},6,[293,684,685],{"class":309},"}\n",[245,687,688,689,692,693,696,697,700],{},"With this file, ",[249,690,691],{},"jscpd ."," fails above 3 % and writes ",[249,694,695],{},"report\u002Fjscpd-report.html"," next to the console output. ",[249,698,699],{},"jscpd --debug"," prints the merged settings without scanning, which is the quickest check that the file was picked up.",[254,702,704],{"id":703},"where-to-go-next","Where to go next",[381,706,707,717],{},[384,708,709],{},[387,710,711,714],{},[390,712,713],{},"You want to",[390,715,716],{},"Read",[407,718,719,728,737,746],{},[387,720,721,724],{},[412,722,723],{},"Fail pull requests on GitHub or GitLab",[412,725,726],{},[274,727,35],{"href":36},[387,729,730,733],{},[412,731,732],{},"Find renamed, near-miss and semantic clones, not only exact copies",[412,734,735],{},[274,736,100],{"href":101},[387,738,739,742],{},[412,740,741],{},"See every option and what it defaults to",[412,743,744],{},[274,745,120],{"href":121},[387,747,748,751],{},[412,749,750],{},"Give the same detector to a coding agent",[412,752,753],{},[274,754,60],{"href":61},[756,757,758],"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}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 .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}",{"title":289,"searchDepth":320,"depth":320,"links":760},[761,762,763,764,765,766],{"id":256,"depth":320,"text":257},{"id":280,"depth":320,"text":281},{"id":349,"depth":320,"text":350},{"id":488,"depth":320,"text":489},{"id":539,"depth":320,"text":540},{"id":703,"depth":320,"text":704},"Scan a repository, read the clones jscpd found and turn the number into a build step, in about ten minutes.","md",null,{},{"icon":23},{"title":20,"description":767},"CgiJa2Zl87lcUEpVPk6zFIN_KYUXDKJpAm5EwIVN0L0",[775,777],{"title":15,"path":16,"stem":17,"description":776,"icon":18,"children":-1},"Every channel installs the same binary; pick the one your project already uses, then check the version.",{"title":25,"path":26,"stem":27,"description":778,"icon":28,"children":-1},"The config file jscpd reads, the handful of keys most projects set, and how to check what a run will use.",1791302986321]