[{"data":1,"prerenderedAt":1145},["ShallowReactive",2],{"navigation_docs":3,"-guides-baseline":239,"-guides-baseline-surround":1140},[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":45,"body":241,"description":1131,"extension":1132,"links":1133,"meta":1134,"navigation":1135,"path":46,"seo":1136,"stem":47,"__hash__":1139},"docs\u002F2.guides\u002F03.baseline.md",{"type":242,"value":243,"toc":1118},"minimark",[244,248,266,271,284,322,330,442,445,463,474,480,483,487,490,557,564,568,573,595,601,609,615,619,643,649,652,656,668,691,697,720,724,853,889,893,980,984,1080,1088,1092,1114],[245,246,247],"p",{},"Most codebases carry duplication that nobody is going to remove this sprint, and a percentage threshold handles it badly: set high, it lets a fresh copy-paste through under the limit; set low, it trips on legacy code the change never touched. A baseline separates the two. The clones that exist today are recorded and accepted, and a build fails only when a change adds a clone that is not among them. You reach for it when you want a gate on pull requests from day one, on a codebase that is not clean.",[249,250,251,252,256,257,261,262,265],"note",{},"Available from jscpd ",[253,254,255],"strong",{},"5.1.0",". The committed file needs nothing beyond the binary; ",[258,259,260],"code",{},"--baseline-from-ref"," needs ",[258,263,264],{},"git"," and the base ref present in the checkout.",[267,268,270],"h2",{"id":269},"run-it","Run it",[245,272,273,274,283],{},"The commands run on a copy of ",[275,276,280],"a",{"href":277,"rel":278},"https:\u002F\u002Fgithub.com\u002Fkucherenko\u002Fjscpd\u002Ftree\u002Fmaster\u002Ffixtures\u002Fmcp-demo",[279],"nofollow",[258,281,282],{},"fixtures\u002Fmcp-demo\u002Fsrc",", which holds three exact clones. The first run records them:",[285,286,292],"pre",{"className":287,"code":288,"filename":289,"language":290,"meta":291,"style":291},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","jscpd src --baseline .jscpd-baseline.json --update-baseline --reporters ai\n","Terminal","bash","",[258,293,294],{"__ignoreMap":291},[295,296,299,303,307,310,313,316,319],"span",{"class":297,"line":298},"line",1,[295,300,302],{"class":301},"sBMFI","jscpd",[295,304,306],{"class":305},"sfazB"," src",[295,308,309],{"class":305}," --baseline",[295,311,312],{"class":305}," .jscpd-baseline.json",[295,314,315],{"class":305}," --update-baseline",[295,317,318],{"class":305}," --reporters",[295,320,321],{"class":305}," ai\n",[285,323,328],{"className":324,"code":326,"language":327,"meta":291},[325],"language-text","Baseline .jscpd-baseline.json updated: 3 fingerprints added, 0 removed (3 total)\nClones:\ninvoice.js:1-6 ~ print\u002Finvoice.js:1-6\ninvoice.js:6-12 ~ print\u002Finvoice.js:7-13\norders.js:1-12 ~ reports\u002Forders.js:1-12\n---\n3 clones · 36.2% duplication\n","text",[258,329,326],{"__ignoreMap":291},[285,331,336],{"className":332,"code":333,"filename":334,"language":335,"meta":291,"style":291},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"version\": 1,\n  \"fingerprints\": {\n    \"0f6fc236d5d07e6b\": 1,\n    \"de96aa427b11c6eb\": 1,\n    \"eac17f2cc970be19\": 1\n  }\n}\n",".jscpd-baseline.json","json",[258,337,338,344,367,382,399,415,430,436],{"__ignoreMap":291},[295,339,340],{"class":297,"line":298},[295,341,343],{"class":342},"sMK4o","{\n",[295,345,347,350,354,357,360,364],{"class":297,"line":346},2,[295,348,349],{"class":342},"  \"",[295,351,353],{"class":352},"spNyl","version",[295,355,356],{"class":342},"\"",[295,358,359],{"class":342},":",[295,361,363],{"class":362},"sbssI"," 1",[295,365,366],{"class":342},",\n",[295,368,370,372,375,377,379],{"class":297,"line":369},3,[295,371,349],{"class":342},[295,373,374],{"class":352},"fingerprints",[295,376,356],{"class":342},[295,378,359],{"class":342},[295,380,381],{"class":342}," {\n",[295,383,385,388,391,393,395,397],{"class":297,"line":384},4,[295,386,387],{"class":342},"    \"",[295,389,390],{"class":301},"0f6fc236d5d07e6b",[295,392,356],{"class":342},[295,394,359],{"class":342},[295,396,363],{"class":362},[295,398,366],{"class":342},[295,400,402,404,407,409,411,413],{"class":297,"line":401},5,[295,403,387],{"class":342},[295,405,406],{"class":301},"de96aa427b11c6eb",[295,408,356],{"class":342},[295,410,359],{"class":342},[295,412,363],{"class":362},[295,414,366],{"class":342},[295,416,418,420,423,425,427],{"class":297,"line":417},6,[295,419,387],{"class":342},[295,421,422],{"class":301},"eac17f2cc970be19",[295,424,356],{"class":342},[295,426,359],{"class":342},[295,428,429],{"class":362}," 1\n",[295,431,433],{"class":297,"line":432},7,[295,434,435],{"class":342},"  }\n",[295,437,439],{"class":297,"line":438},8,[295,440,441],{"class":342},"}\n",[245,443,444],{},"Commit the file. From now on the gate is one flag:",[285,446,448],{"className":287,"code":447,"filename":289,"language":290,"meta":291,"style":291},"jscpd src --baseline .jscpd-baseline.json --fail-on-new-clones\n",[258,449,450],{"__ignoreMap":291},[295,451,452,454,456,458,460],{"class":297,"line":298},[295,453,302],{"class":301},[295,455,306],{"class":305},[295,457,309],{"class":305},[295,459,312],{"class":305},[295,461,462],{"class":305}," --fail-on-new-clones\n",[245,464,465,466,469,470,473],{},"It prints the three clones without a marker and exits 0. Copy ",[258,467,468],{},"returns.js"," to ",[258,471,472],{},"refunds.js"," and run the same command again:",[285,475,478],{"className":476,"code":477,"language":327,"meta":291},[325],"Clone found (javascript)\n - invoice.js [1:1 - 6:72] (6 lines, 105 tokens)\n   print\u002Finvoice.js [1:1 - 6:72]\nClone found (javascript)\n - invoice.js [6:71 - 12:2] (7 lines, 93 tokens)\n   print\u002Finvoice.js [7:53 - 13:2]\nClone found (javascript)\n - orders.js [1:1 - 12:2] (12 lines, 124 tokens)\n   reports\u002Forders.js [1:1 - 12:2]\nClone found (javascript) [NEW]\n - refunds.js [1:1 - 10:2] (10 lines, 104 tokens)\n   returns.js [1:1 - 10:2]\nFound 4 clones (1 new).\nERROR: jscpd found 1 new clones not in the baseline (allowed: 0)\n",[258,479,477],{"__ignoreMap":291},[245,481,482],{},"The run exits 1. The three old clones are still listed and still count in the percentage; only the fourth fails the build.",[267,484,486],{"id":485},"reading-the-output","Reading the output",[245,488,489],{},"Each key in the baseline file is a hash of a duplicated fragment's content, and the value is how many clones share it. A clone is new when its hash is absent, or when more clones carry it than the file allows, so a third copy of a fragment that has one recorded twin is new. Nothing about paths or line numbers goes into the hash: moving a file, shifting lines above the fragment or switching line endings leaves the gate quiet, and the file diffs one line per fingerprint when you refresh it.",[245,491,492,493,496,497,500,501,503,504,507,508,511,512,515,516,521,522,525,526,529,530,535,536,539,540,543,544,549,550,511,553,556],{},"The console reporters mark a new clone with ",[258,494,495],{},"[NEW]"," and count them in ",[258,498,499],{},"Found 4 clones (1 new)",". The other reporters carry the same information: ",[258,502,335],{}," adds ",[258,505,506],{},"isNew"," to each clone and ",[258,509,510],{},"newClones"," and ",[258,513,514],{},"newDuplicatedLines"," to the totals, ",[275,517,518],{"href":158},[258,519,520],{},"sarif"," reports a new clone at level ",[258,523,524],{},"error"," and the rest at ",[258,527,528],{},"warning",", so GitHub code scanning highlights only the regression, ",[275,531,532],{"href":163},[258,533,534],{},"codeclimate"," gives it severity ",[258,537,538],{},"major"," against ",[258,541,542],{},"minor",", and ",[275,545,546],{"href":168},[258,547,548],{},"openmetrics"," adds the ",[258,551,552],{},"jscpd_new_clones",[258,554,555],{},"jscpd_new_duplicated_lines"," gauges.",[245,558,559,560,563],{},"The percentage in the table counts every clone, old and new, so a ",[258,561,562],{},"--threshold"," in the same run keeps watching the whole picture; when either gate trips, the run exits 1.",[267,565,567],{"id":566},"common-tasks","Common tasks",[569,570,572],"h3",{"id":571},"accept-new-duplication-in-a-pull-request","Accept new duplication in a pull request",[285,574,576],{"className":287,"code":575,"filename":289,"language":290,"meta":291,"style":291},"jscpd src --baseline .jscpd-baseline.json --update-baseline --reporters silent\n",[258,577,578],{"__ignoreMap":291},[295,579,580,582,584,586,588,590,592],{"class":297,"line":298},[295,581,302],{"class":301},[295,583,306],{"class":305},[295,585,309],{"class":305},[295,587,312],{"class":305},[295,589,315],{"class":305},[295,591,318],{"class":305},[295,593,594],{"class":305}," silent\n",[285,596,599],{"className":597,"code":598,"language":327,"meta":291},[325],"Baseline .jscpd-baseline.json updated: 1 fingerprints added, 0 removed (4 total)\nDuplications detection: Found 4 exact clones with 35(44.30%) duplicated lines in 7 (1 formats) files.\n",[258,600,598],{"__ignoreMap":291},[245,602,603,604,511,606,359],{},"Commit the file with the change; the diff shows one added fingerprint, so the reviewer sees that the pull request accepts one more clone. The same command after a refactoring drops what is gone. After deleting ",[258,605,472],{},[258,607,608],{},"reports\u002Forders.js",[285,610,613],{"className":611,"code":612,"language":327,"meta":291},[325],"Baseline .jscpd-baseline.json updated: 0 fingerprints added, 2 removed (2 total)\nDuplications detection: Found 2 exact clones with 13(22.81%) duplicated lines in 5 (1 formats) files.\n",[258,614,612],{"__ignoreMap":291},[569,616,618],{"id":617},"allow-a-budget-of-new-clones","Allow a budget of new clones",[285,620,622],{"className":287,"code":621,"filename":289,"language":290,"meta":291,"style":291},"jscpd src --baseline .jscpd-baseline.json --fail-on-new-clones 1 --reporters ai\n",[258,623,624],{"__ignoreMap":291},[295,625,626,628,630,632,634,637,639,641],{"class":297,"line":298},[295,627,302],{"class":301},[295,629,306],{"class":305},[295,631,309],{"class":305},[295,633,312],{"class":305},[295,635,636],{"class":305}," --fail-on-new-clones",[295,638,363],{"class":362},[295,640,318],{"class":305},[295,642,321],{"class":305},[285,644,647],{"className":645,"code":646,"language":327,"meta":291},[325],"Clones:\ninvoice.js:1-6 ~ print\u002Finvoice.js:1-6\ninvoice.js:6-12 ~ print\u002Finvoice.js:7-13\norders.js:1-12 ~ reports\u002Forders.js:1-12\nrefunds.js:1-10 ~ returns.js:1-10\n---\n4 clones · 44.3% duplication\n",[258,648,646],{"__ignoreMap":291},[245,650,651],{},"The run exits 0: one new clone is within the allowance, a second one would fail. Without a number the allowance is 0.",[569,653,655],{"id":654},"baseline-from-a-git-ref","Baseline from a git ref",[245,657,658,659,661,662,664,665,359],{},"When you would rather keep nothing in the repository, ",[258,660,260],{}," builds the baseline from a git ref's tree: jscpd checks the ref out into a temporary worktree, scans it with the same configuration and compares the two results in memory. On a branch that adds ",[258,663,472],{}," on top of ",[258,666,667],{},"main",[285,669,671],{"className":287,"code":670,"filename":289,"language":290,"meta":291,"style":291},"jscpd src --baseline-from-ref main --fail-on-new-clones --reporters ai\n",[258,672,673],{"__ignoreMap":291},[295,674,675,677,679,682,685,687,689],{"class":297,"line":298},[295,676,302],{"class":301},[295,678,306],{"class":305},[295,680,681],{"class":305}," --baseline-from-ref",[295,683,684],{"class":305}," main",[295,686,636],{"class":305},[295,688,318],{"class":305},[295,690,321],{"class":305},[285,692,695],{"className":693,"code":694,"language":327,"meta":291},[325],"Clones:\ninvoice.js:1-6 ~ print\u002Finvoice.js:1-6\ninvoice.js:6-12 ~ print\u002Finvoice.js:7-13\norders.js:1-12 ~ reports\u002Forders.js:1-12\nrefunds.js:1-10 ~ returns.js:1-10\n---\n4 clones · 44.3% duplication\nERROR: jscpd found 1 new clones not in the baseline (allowed: 0)\n",[258,696,694],{"__ignoreMap":291},[245,698,699,700,703,704,707,708,711,712,715,716,719],{},"The run scans twice, the base tree and the working tree, and the ref has to exist locally. In a shallow CI checkout ",[258,701,702],{},"origin\u002Fmain"," is missing, and jscpd exits 1 with ",[258,705,706],{},"git ref 'origin\u002Fmain' not found"," and the advice to fetch it; ",[258,709,710],{},"git fetch origin main"," followed by ",[258,713,714],{},"--baseline-from-ref FETCH_HEAD"," is the smallest fix, a full fetch the usual one. The flag cannot be combined with ",[258,717,718],{},"--baseline",".",[267,721,723],{"id":722},"in-ci","In CI",[285,725,730],{"className":726,"code":727,"filename":728,"language":729,"meta":291,"style":291},"language-yaml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","on: [pull_request]\n\njobs:\n  jscpd:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n      - uses: kucherenko\u002Fjscpd@v5\n        with:\n          baseline: .jscpd-baseline.json\n          fail-on-new-clones: true\n          reporters: console,sarif\n",".github\u002Fworkflows\u002Fjscpd.yml","yaml",[258,731,732,749,755,764,771,781,788,801,812,820,831,842],{"__ignoreMap":291},[295,733,734,738,740,743,746],{"class":297,"line":298},[295,735,737],{"class":736},"sfNiH","on",[295,739,359],{"class":342},[295,741,742],{"class":342}," [",[295,744,745],{"class":305},"pull_request",[295,747,748],{"class":342},"]\n",[295,750,751],{"class":297,"line":346},[295,752,754],{"emptyLinePlaceholder":753},true,"\n",[295,756,757,761],{"class":297,"line":369},[295,758,760],{"class":759},"swJcz","jobs",[295,762,763],{"class":342},":\n",[295,765,766,769],{"class":297,"line":384},[295,767,768],{"class":759},"  jscpd",[295,770,763],{"class":342},[295,772,773,776,778],{"class":297,"line":401},[295,774,775],{"class":759},"    runs-on",[295,777,359],{"class":342},[295,779,780],{"class":305}," ubuntu-latest\n",[295,782,783,786],{"class":297,"line":417},[295,784,785],{"class":759},"    steps",[295,787,763],{"class":342},[295,789,790,793,796,798],{"class":297,"line":432},[295,791,792],{"class":342},"      -",[295,794,795],{"class":759}," uses",[295,797,359],{"class":342},[295,799,800],{"class":305}," actions\u002Fcheckout@v4\n",[295,802,803,805,807,809],{"class":297,"line":438},[295,804,792],{"class":342},[295,806,795],{"class":759},[295,808,359],{"class":342},[295,810,811],{"class":305}," kucherenko\u002Fjscpd@v5\n",[295,813,815,818],{"class":297,"line":814},9,[295,816,817],{"class":759},"        with",[295,819,763],{"class":342},[295,821,823,826,828],{"class":297,"line":822},10,[295,824,825],{"class":759},"          baseline",[295,827,359],{"class":342},[295,829,830],{"class":305}," .jscpd-baseline.json\n",[295,832,834,837,839],{"class":297,"line":833},11,[295,835,836],{"class":759},"          fail-on-new-clones",[295,838,359],{"class":342},[295,840,841],{"class":736}," true\n",[295,843,845,848,850],{"class":297,"line":844},12,[295,846,847],{"class":759},"          reporters",[295,849,359],{"class":342},[295,851,852],{"class":305}," console,sarif\n",[245,854,855,858,859,862,863,866,867,870,871,874,875,878,879,882,883,885,886,888],{},[258,856,857],{},"fail-on-new-clones: true"," is the bare flag, an integer is the allowance. For the ref variant, replace ",[258,860,861],{},"baseline"," with ",[258,864,865],{},"baseline-from-ref: origin\u002F${{ github.base_ref }}"," and give ",[258,868,869],{},"actions\u002Fcheckout"," ",[258,872,873],{},"fetch-depth: 0",". On GitLab, the script line is ",[258,876,877],{},"jscpd . --baseline .jscpd-baseline.json --fail-on-new-clones --reporters console,codeclimate,openmetrics",", and the ",[275,880,881],{"href":36},"CI guide"," has the artifacts block around it, so the merge request shows the new clone as a ",[258,884,538],{}," Code Quality issue and the metrics widget shows the ",[258,887,552],{}," delta.",[267,890,892],{"id":891},"limits","Limits",[894,895,896,916,930,941,968],"ul",{},[897,898,899,900,903,904,907,908,911,912,915],"li",{},"Put the paths before ",[258,901,902],{},"--fail-on-new-clones"," or give it a number. The flag takes an optional value, so ",[258,905,906],{},"--fail-on-new-clones src"," reads ",[258,909,910],{},"src"," as the number and exits 2 with ",[258,913,914],{},"error: invalid value 'src' for '--fail-on-new-clones [\u003CN>]'",". The GitHub Action orders the arguments itself.",[897,917,918,261,921,923,924,926,927,929],{},[258,919,920],{},"--update-baseline",[258,922,718],{}," and exits 1 without it; a ",[258,925,718],{}," that names a missing file exits 1 and tells you to run with ",[258,928,920],{}," once.",[897,931,932,933,936,937,940],{},"Record and gate with the same options. The file lists what one run found, so a run with ",[258,934,935],{},"--ignore-identifiers"," or ",[258,938,939],{},"--max-gap-lines"," added finds clones the file does not know, and they count as new.",[897,942,943,511,946,949,950,952,953,511,955,957,958,960,961,964,965,719],{},[258,944,945],{},"--dashboard",[258,947,948],{},"--health"," do not build a baseline: they warn and ignore ",[258,951,718],{},", ",[258,954,260],{},[258,956,920],{},", and they refuse ",[258,959,902],{}," with an error. ",[258,962,963],{},"--complexity"," never detects clones, so it ignores the whole family with a warning. See the ",[275,966,967],{"href":76},"dashboard guide",[897,969,970,972,973,975,976,979],{},[258,971,260],{}," runs ",[258,974,264],{},", so it does not work in the ",[258,977,978],{},"ghcr.io\u002Fkucherenko\u002Fjscpd"," image, which holds only the binary.",[267,981,983],{"id":982},"options","Options",[985,986,987,1006],"table",{},[988,989,990],"thead",{},[991,992,993,997,1000,1003],"tr",{},[994,995,996],"th",{},"Flag",[994,998,999],{},"Config key",[994,1001,1002],{},"Effect",[994,1004,1005],{},"Default",[1007,1008,1009,1027,1044,1061],"tbody",{},[991,1010,1011,1017,1021,1024],{},[1012,1013,1014],"td",{},[258,1015,1016],{},"--baseline \u003CFILE>",[1012,1018,1019],{},[258,1020,861],{},[1012,1022,1023],{},"Read the fingerprints from the file; a clone whose fingerprint is absent is new",[1012,1025,1026],{},"none",[991,1028,1029,1033,1036,1041],{},[1012,1030,1031],{},[258,1032,920],{},[1012,1034,1035],{},"command line only",[1012,1037,1038,1039],{},"Rewrite the file from this run, create it when missing, print the added and removed counts; needs ",[258,1040,718],{},[1012,1042,1043],{},"off",[991,1045,1046,1051,1056,1059],{},[1012,1047,1048],{},[258,1049,1050],{},"--fail-on-new-clones [N]",[1012,1052,1053],{},[258,1054,1055],{},"failOnNewClones",[1012,1057,1058],{},"Exit 1 when more than N clones are new; N is 0 without a number; needs one of the two baselines",[1012,1060,1043],{},[991,1062,1063,1068,1073,1078],{},[1012,1064,1065],{},[258,1066,1067],{},"--baseline-from-ref \u003CREF>",[1012,1069,1070],{},[258,1071,1072],{},"baselineFromRef",[1012,1074,1075,1076],{},"Build the baseline from the ref's tree in a temporary worktree; conflicts with ",[258,1077,718],{},[1012,1079,1026],{},[245,1081,1082,1084,1085,719],{},[275,1083,120],{"href":121}," lists them with the rest of the flags; the keys go in ",[275,1086,1087],{"href":126},".jscpd.json",[267,1089,1091],{"id":1090},"related","Related",[894,1093,1094,1099,1104,1109],{},[897,1095,1096,1098],{},[275,1097,35],{"href":36}," for the workflows around the gate on GitHub and GitLab.",[897,1100,1101,1103],{},[275,1102,40],{"href":41}," for the same baseline in a hook, so legacy clones do not block commits.",[897,1105,1106,1108],{},[275,1107,70],{"href":71}," for the trend of the number the threshold watches.",[897,1110,1111,1113],{},[275,1112,130],{"href":131}," for every code a gated run can return.",[1115,1116,1117],"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 .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 .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":291,"searchDepth":346,"depth":346,"links":1119},[1120,1121,1122,1127,1128,1129,1130],{"id":269,"depth":346,"text":270},{"id":485,"depth":346,"text":486},{"id":566,"depth":346,"text":567,"children":1123},[1124,1125,1126],{"id":571,"depth":369,"text":572},{"id":617,"depth":369,"text":618},{"id":654,"depth":369,"text":655},{"id":722,"depth":346,"text":723},{"id":891,"depth":346,"text":892},{"id":982,"depth":346,"text":983},{"id":1090,"depth":346,"text":1091},"Record the clones a codebase already has in a baseline file or take them from a git ref, and fail the build only when a change adds a clone.","md",null,{},{"icon":48},{"title":1137,"description":1138},"Baseline and new-clone gate in jscpd","jscpd --baseline, --update-baseline, --fail-on-new-clones and --baseline-from-ref let a build tolerate the duplication it has and fail only on new clones.","67hrx8oK-NEj3gn1ISfA_1w7D_UQxWSdJ9vll7yu300",[1141,1143],{"title":40,"path":41,"stem":42,"description":1142,"icon":43,"children":-1},"Run jscpd at git commit with the pre-commit framework, Husky or a plain git hook, so a copy-paste is caught before it leaves the machine.",{"title":50,"path":51,"stem":52,"description":1144,"icon":53,"children":-1},"Scan a repository of many packages so the report holds the clones you can act on, with --skip-local and --skip-isolated to drop the pairs you accept.",1791302985922]