Reporters

JSON Reporter

Generate JSON reports for CI/CD integration.

Usage

jscpd --reporters json ./src

Output

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
    }
  }
}

CI/CD Integration

Use JSON output for automated pipelines:

.github/workflows/jscpd.yml
- name: Check for duplicates
  run: |
    npx jscpd --reporters json --threshold 5 ./src
    cat jscpd-report.json