[{"data":1,"prerenderedAt":671},["ShallowReactive",2],{"navigation_docs":3,"-reference-exit-codes":249,"-reference-exit-codes-surround":662,"page-views-\u002Freference\u002Fexit-codes":667},[4,29,104,124,194],{"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,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},"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},"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",{"id":250,"title":140,"body":251,"description":655,"extension":656,"links":657,"meta":658,"navigation":659,"path":141,"seo":660,"stem":142,"__hash__":661},"docs\u002F4.reference\u002F3.exit-codes.md",{"type":252,"value":253,"toc":650},"minimark",[254,258,453,460,465,558,586,594,598,627,631,646],[255,256,257],"p",{},"A scan that finds clones exits 0: finding duplication is the normal result, not a failure. The exit code changes only when you ask for a gate or when the run itself could not do its job. Pre-commit hooks and CI systems read this code, so it is what turns a scan into a build step.",[259,260,261,277],"table",{},[262,263,264],"thead",{},[265,266,267,271,274],"tr",{},[268,269,270],"th",{},"Code",[268,272,273],{},"When",[268,275,276],{},"Controlled by",[278,279,280,294,321,343,371,404,424,440],"tbody",{},[265,281,282,289,292],{},[283,284,285],"td",{},[286,287,288],"code",{},"0",[283,290,291],{},"The run finished and no gate below tripped",[283,293],{},[265,295,296,301,312],{},[283,297,298],{},[286,299,300],{},"1",[283,302,303,304,307,308,311],{},"Total duplication is above ",[286,305,306],{},"--threshold"," (strictly greater: 50.0 % with ",[286,309,310],{},"--threshold 50"," passes)",[283,313,314,317,318],{},[286,315,316],{},"--threshold \u003CPERCENT>",", config ",[286,319,320],{},"threshold",[265,322,323,332,335],{},[283,324,325,328,329,331],{},[286,326,327],{},"N"," (",[286,330,300],{}," without a number)",[283,333,334],{},"At least one clone was found",[283,336,337,317,340],{},[286,338,339],{},"--exit-code [N]",[286,341,342],{},"exitCode",[265,344,345,349,358],{},[283,346,347],{},[286,348,300],{},[283,350,351,352,354,355,357],{},"More than ",[286,353,327],{}," clones are new against the baseline (",[286,356,327],{}," is 0 without a number)",[283,359,360,363,364,367,368],{},[286,361,362],{},"--fail-on-new-clones [N]"," with ",[286,365,366],{},"--baseline"," or ",[286,369,370],{},"--baseline-from-ref",[265,372,373,377,395],{},[283,374,375],{},[286,376,300],{},[283,378,379,380,383,384,387,388,391,392],{},"The scan analyzed no file: the paths exist but nothing matched ",[286,381,382],{},"--format",", ",[286,385,386],{},"--ignore"," and ",[286,389,390],{},"--pattern",", or every file was below ",[286,393,394],{},"--min-tokens",[283,396,397,317,400,403],{},[286,398,399],{},"--fail-on-empty",[286,401,402],{},"failOnEmpty"," (5.2.1+)",[265,405,406,410,418],{},[283,407,408],{},[286,409,300],{},[283,411,412,413,417],{},"A copy of protected code shows up in a place a ",[414,415,416],"a",{"href":101},"boundary rule"," keeps it out of, or a rule has a mistake",[283,419,420,423],{},[286,421,422],{},"boundaries"," in the config file",[265,425,426,430,437],{},[283,427,428],{},[286,429,300],{},[283,431,432,433,436],{},"A format name that ",[286,434,435],{},"jscpd --list"," does not know, a scan path that does not exist, or a reporter that could not write its file",[283,438,439],{},"Always, since 5.2.1; before that these cases wrote an empty report and exited 0",[265,441,442,447,450],{},[283,443,444],{},[286,445,446],{},"2",[283,448,449],{},"The command line itself is wrong: an unknown flag or a value of the wrong type",[283,451,452],{},"The argument parser",[255,454,455,456,459],{},"Reports are written before the gates run, so a failing job still leaves its JSON, HTML or SARIF file in ",[286,457,458],{},"--output",".",[461,462,464],"h2",{"id":463},"examples","Examples",[466,467,473],"pre",{"className":468,"code":469,"filename":470,"language":471,"meta":472,"style":472},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","jscpd . --threshold 3            # exit 1 when duplication > 3 %\njscpd . --exit-code              # exit 1 when any clone is found\njscpd . --exit-code 3            # the same, with code 3\njscpd . --baseline .jscpd-baseline.json --fail-on-new-clones   # exit 1 on a clone that is not in the baseline\njscpd . --fail-on-empty          # exit 1 when nothing was analyzed\n","Terminal","bash","",[286,474,475,499,512,526,545],{"__ignoreMap":472},[476,477,480,484,488,491,495],"span",{"class":478,"line":479},"line",1,[476,481,483],{"class":482},"sBMFI","jscpd",[476,485,487],{"class":486},"sfazB"," .",[476,489,490],{"class":486}," --threshold",[476,492,494],{"class":493},"sbssI"," 3",[476,496,498],{"class":497},"sHwdD","            # exit 1 when duplication > 3 %\n",[476,500,502,504,506,509],{"class":478,"line":501},2,[476,503,483],{"class":482},[476,505,487],{"class":486},[476,507,508],{"class":486}," --exit-code",[476,510,511],{"class":497},"              # exit 1 when any clone is found\n",[476,513,515,517,519,521,523],{"class":478,"line":514},3,[476,516,483],{"class":482},[476,518,487],{"class":486},[476,520,508],{"class":486},[476,522,494],{"class":493},[476,524,525],{"class":497},"            # the same, with code 3\n",[476,527,529,531,533,536,539,542],{"class":478,"line":528},4,[476,530,483],{"class":482},[476,532,487],{"class":486},[476,534,535],{"class":486}," --baseline",[476,537,538],{"class":486}," .jscpd-baseline.json",[476,540,541],{"class":486}," --fail-on-new-clones",[476,543,544],{"class":497},"   # exit 1 on a clone that is not in the baseline\n",[476,546,548,550,552,555],{"class":478,"line":547},5,[476,549,483],{"class":482},[476,551,487],{"class":486},[476,553,554],{"class":486}," --fail-on-empty",[476,556,557],{"class":497},"          # exit 1 when nothing was analyzed\n",[466,559,561],{"className":468,"code":560,"filename":470,"language":471,"meta":472,"style":472},"jscpd fixtures\u002Ffail-on-empty-demo\u002Fcode --format nosuchlang\necho $?\n",[286,562,563,576],{"__ignoreMap":472},[476,564,565,567,570,573],{"class":478,"line":479},[476,566,483],{"class":482},[476,568,569],{"class":486}," fixtures\u002Ffail-on-empty-demo\u002Fcode",[476,571,572],{"class":486}," --format",[476,574,575],{"class":486}," nosuchlang\n",[476,577,578,582],{"class":478,"line":501},[476,579,581],{"class":580},"s2Zo4","echo",[476,583,585],{"class":584},"sTEyZ"," $?\n",[466,587,592],{"className":588,"code":590,"language":591,"meta":472},[589],"language-text","Error: --format: 'nosuchlang' is not a supported format (run with --list to see supported formats)\n1\n","text",[286,593,590],{"__ignoreMap":472},[461,595,597],{"id":596},"in-ci","In CI",[255,599,600,601,367,603,606,607,610,611,614,615,618,619,622,623,626],{},"GitHub Actions and GitLab CI fail a step on any non-zero code, so ",[286,602,306],{},[286,604,605],{},"--fail-on-new-clones"," is all a gate needs. Two things hide the code: a shell pipe (",[286,608,609],{},"jscpd . | tee log"," exits with ",[286,612,613],{},"tee","'s code unless ",[286,616,617],{},"set -o pipefail"," is on) and ",[286,620,621],{},"|| true",". The ",[414,624,625],{"href":36},"CI guide"," has the workflows.",[461,628,630],{"id":629},"see-also","See also",[632,633,634,640],"ul",{},[635,636,637,639],"li",{},[414,638,130],{"href":131}," for the flags above.",[635,641,642,645],{},[414,643,644],{"href":46},"Baseline"," for gating on new duplication only.",[647,648,649],"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 .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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 .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}",{"title":472,"searchDepth":501,"depth":501,"links":651},[652,653,654],{"id":463,"depth":501,"text":464},{"id":596,"depth":501,"text":597},{"id":629,"depth":501,"text":630},"What makes a jscpd run exit with 0, 1, 2 or a code of your own, and which flag controls each case.","md",null,{},{"icon":143},{"title":140,"description":655},"7R3Bh3Gj5m8mzlwc74xGd-OvmdI94RF8k4FdpVN532I",[663,665],{"title":135,"path":136,"stem":137,"description":664,"icon":138,"children":-1},"Every key of .jscpd.json and the jscpd section of package.json, where jscpd looks for them, and how they combine with the command line.",{"title":145,"path":146,"stem":147,"description":666,"icon":150,"children":-1},"The 16 reporters of jscpd, what each one writes, and which to pick for a terminal, a script, a merge request widget or a README.",{"\u002Freference\u002Fexit-codes":668},{"views":669,"visits":670},25,14,1795510271449]