Reporters

CodeClimate reporter

GitLab Code Quality issues in the CodeClimate format, two per clone, so merge requests show duplication on the changed lines.

-r codeclimate (alias gitlab) writes the issue format GitLab reads for its Code Quality widget: each clone becomes an issue at each of its two locations, with a fingerprint that stays the same across pipelines, so a merge request lists which duplication it adds and which it removes. GitLab takes SARIF as security findings only; this reporter is how clones reach a merge request as quality issues. Available since jscpd 5.1.0.

Run it

Terminal
jscpd . -r codeclimate --output report
CodeClimate report saved to report/gl-code-quality-report.json
.jscpd.json
{
  "reporters": ["console", "codeclimate"],
  "output": "report"
}

The output

The file is a JSON array of issues. One of them, from the repository's fixtures/mcp-demo folder scanned with --ignore-identifiers --ignore-literals --max-gap-lines 1:

report/gl-code-quality-report.json
{
  "type": "issue",
  "check_name": "jscpd/similar-code",
  "description": "Duplicated code block (197 tokens), duplicated at src/print/invoice.js:1",
  "categories": ["Duplication"],
  "severity": "minor",
  "fingerprint": "4b46d31b85a7ff81",
  "location": {
    "path": "src/invoice.js",
    "lines": { "begin": 1, "end": 12 }
  },
  "other_locations": [
    {
      "path": "src/print/invoice.js",
      "lines": { "begin": 1, "end": 13 }
    }
  ]
}
FieldMeaning
check_nameThe rule id of the clone's kind, the same as in SARIF: jscpd/duplicate-code, jscpd/renamed-code, jscpd/similar-code, jscpd/similar-function (5.4.0+) or jscpd/semantic-code (5.3.3+)
descriptionThe token count and the other copy's location
severityminor, or major under a gate (below)
fingerprintA hash of the pair's content, the path and the start line, so GitLab tells an existing issue from a new one across pipelines, and a file that duplicates itself gets two distinct issues
locationThe copy this issue is anchored at: a path relative to the scanned directory and a line range
other_locationsThe other copy; part of the CodeClimate specification, ignored by GitLab, kept for other consumers

Every clone yields two issues, one anchored at each copy, so the widget annotates the duplication whichever side a merge request touches.

Where it shows up

Declare the file as a codequality report artifact. The Code Quality widget is available in every GitLab tier.

.gitlab-ci.yml
jscpd:
  stage: test
  image: node:22
  before_script:
    - npm install -g jscpd@5
  script:
    - jscpd . -r console,codeclimate --output report
  artifacts:
    when: always
    reports:
      codequality: report/gl-code-quality-report.json

The merge request then shows the duplication issues it adds and the ones it resolves against the target branch.

With gates

SeverityWhen
minorThe default
majorThe clone is new against --baseline or --baseline-from-ref, or the duplication of the run is above --threshold; then every issue is major

The comparison with the threshold is strictly greater, the same one that fails the build. --kind keeps only the kinds you name.

Options

FlagEffect on the file
-o, --outputThe directory of gl-code-quality-report.json
-t, --threshold PEvery issue at major when the run is above P
--baseline, --baseline-from-refmajor for new clones
-a, --absoluteAbsolute paths in reports