jscpd --reporters json ./src
The JSON reporter generates a jscpd-report.json file with structured data:
{
"duplicates": [
{
"format": "javascript",
"lines": 10,
"tokens": 120,
"firstFile": {
"name": "src/utils.js",
"start": 10,
"end": 20
},
"secondFile": {
"name": "src/helpers.js",
"start": 5,
"end": 15
}
}
],
"statistics": {
"total": {
"lines": 1000,
"tokens": 15000,
"sources": 50,
"clones": 5,
"duplicatedLines": 50,
"percentage": 5.0
}
}
}
Use JSON output for automated pipelines:
- name: Check for duplicates
run: |
npx jscpd --reporters json --threshold 5 ./src
cat jscpd-report.json