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