Reference

GitHub Action

41 views
The inputs and outputs of kucherenko/jscpd@v5, generated from the action.yml of jscpd 5.4.3.

kucherenko/jscpd@v5 runs the same binary as the command line, so every input below is a CLI option with the same name. The CI guide shows the workflows; this page is the list.

.github/workflows/jscpd.yml
- uses: kucherenko/jscpd@v5
  with:
    threshold: 3

Inputs

InputWhat it doesDefault
pathPaths to scan for duplicates (space-separated).
configPath to .jscpd.json config file—
min-tokensMinimum number of tokens to consider a duplicate50
min-linesMinimum number of lines to consider a duplicate5
max-linesMaximum lines per block to consider—
modeDetection mode: mild, weak, or strictmild
formatComma-separated list of file extensions/formats to check—
ignoreComma-separated glob patterns to ignore—
ignore-patternComma-separated regex patterns to skip matching tokens—
reportersComma-separated list of reporters (console, json, xml, csv, html, markdown, badge, sarif, ai, xcode, console-full, threshold, silent)console
outputOutput directory for file reportersreport
report-nameBase name of the report files, without the extension (jscpd --report-name; default jscpd-report). The action reads .json and .sarif back, so set it here, not only as reportName in .jscpd.json—
thresholdMaximum duplication percentage before exit 1—
baselinePath to a clone baseline file (e.g. .jscpd-baseline.json): clones absent from it are reported as new—
update-baselineRewrite the baseline file from the current run (requires baseline)false
fail-on-new-clonesExit 1 when new clones are found (requires baseline or baseline-from-ref). Use 'true' for zero tolerance, or an integer N to allow up to N new clones—
fail-on-emptyExit 1 when the scan analyzes no files: the paths exist but nothing matched the format, ignore or pattern filtersfalse
baseline-from-refCompare against an ephemeral baseline built from a git ref's tree (e.g. origin/main); needs the ref fetched (fetch-depth: 0). Conflicts with baseline—
historyDuplication and health trend over git history: 'true' for the last 30 commits of the branch (or the config's history range), or a range of commits to scan (e.g. v5.0.0..HEAD); 'false' leaves it off. Prints charts and a table in the log and needs the commits fetched (fetch-depth: 0, or 30 for 'true')—
blameEnrich clones with git blame datafalse
exit-codeExit with code when duplicates found. Use 'true' for default code 1, or an integer like '2' for a custom code—
patternGlob pattern to find files to scan—
max-sizeSkip files larger than SIZE (e.g. 100kb, 1mb)—
skip-localSkip clones where both fragments are in the same directoryfalse
ignore-caseIgnore case of symbols (experimental)false
ignore-identifiersTreat identifiers as equal (Type-2 clones: renamed variables, functions, types): 'consistent' lets a name stand for one name on the other side only, 'blind' lets any name match any other, in similarity too, 'true' takes the matching from the config's ignoreIdentifiers, else consistentfalse
ignore-literalsTreat all string and numeric literals as equalfalse
ignore-annotationsSkip annotations and decorators (@Name, @Name(...))false
max-gap-linesMerge clones separated by at most N unmatched lines into one near-miss clone (Type-3); 0 disables0
similarityReport pairs of functions whose normalized syntax trees share at least this ratio of their subtrees (a number in (0, 1], such as 0.8) as near-miss clones. JavaScript, TypeScript, Python, Java, Kotlin, Scala, C#, Go, Rust, C, C++, PHP, Ruby, Swift and Clojure; test files are left out. Not set: the config's value, else off—
min-nodesThe fewest nodes of a normalized syntax tree a function needs for similarity to compare it. Not set: the config's value, else 20—
follow-symlinksFollow symbolic linksfalse
no-gitignoreDo not respect .gitignore filesfalse
absoluteUse absolute paths in reportsfalse
formats-extsCustom format-to-extension mappings (e.g. javascript:es,es6;dart:dt)—
formats-namesCustom format-to-filename mappings (e.g. python:Tiltfile,BUCK;ruby:Buildfile)—
versionVersion of jscpd to install. Empty (the default) installs the release this action ref belongs to, so pinning the action to a release tag or its SHA pins jscpd too; a commit between releases gets the release before it. 'latest' installs the newest release—
install-prefixInstallation directory for the jscpd binary on Linux/macOS (default: ~/.local/bin). Windows installs jscpd with npm and ignores it—
skip-installSkip installation (use when jscpd/cpd is already installed)false
extra-argsAdditional arguments passed directly to cpd/jscpd—
upload-reportUpload the report directory as a workflow artifactfalse
upload-sarifUpload SARIF report to GitHub Code Scanningtrue

Outputs

OutputWhat it holds
duplication-percentagePercentage of duplicated code found
clones-foundNumber of clone pairs found
duplicated-linesNumber of duplicated lines
total-linesTotal number of lines scanned
files-countNumber of source files scanned
report-pathPath to the output directory
sarif-pathPath to the SARIF report file (empty if not generated)
exit-codeExit code from jscpd (non-zero if threshold exceeded or --exit-code used)

Read an output in a later step as ${{ steps.<id>.outputs.<name> }} after giving the jscpd step an id.