New Features
- Type-2 clone detection:
--ignore-identifiers,--ignore-literals,--ignore-annotations— three opt-in flags (config keysignoreIdentifiers,ignoreLiterals,ignoreAnnotations, GitHub Action inputs of the same names) normalize token classes before hashing, so blocks that differ only in names, literal values or annotations are found. Identifiers hash as one class while keywords keep their value, strings and numbers stay distinct classes, and@Name(...)runs are dropped in Java, Kotlin, Scala, Groovy, Python, Dart, Swift, JavaScript and TypeScript (@interfacedeclarations are kept). Every clone now carries akind:exactorrenamed. A run without the flags is unchanged apart from the additive"kind": "exact"JSON field. Seefixtures/type2-demo. (#998, #1019) - Near-miss clone merging with
--max-gap-lines N— a copy with a line inserted, removed or changed in the middle used to show up as two shorter clones. With--max-gap-lines N(configmaxGapLines, Action inputmax-gap-lines, default0= off) clones of one file pair whose fragments follow each other in both files with at mostNunmatched lines between them are merged into one clone of kindsimilarwith asimilarityvalue (matched tokens over the merged span). A merge whose similarity would fall below0.5is refused, duplicated-line statistics count only the matched lines, and a merge of renamed halves is reported assimilar. Seefixtures/type3-demo. (#999, #1020, #1030) - Function-level similarity for JavaScript and TypeScript with
--similarity RATIO— edits spread through a function rather than concentrated in one gap still escape a token window.--similarity(configsimilarity, Action inputsimilarity, a number in(0, 1]; the default1means exact matches only, so nothing runs until you lower it) compares every function, method and arrow function by the bag of 4-grams over its syntax-tree node types, indexed with MinHash, and reports pairs at or above the ratio assimilarclones spanning the whole functions. Names and literals do not take part: a renamed copy scores1.0, one inserted line about0.9, two inserted statements plus renames about0.75. Everysimilarclone records itsmethod(gaporast) because the two scores are not on the same scale. The MCPcheck_duplicationtool accepts the samesimilarityargument. (#999, #727, #1021) - Clone kinds in every reporter — console prints
Clone found (javascript, renamed)andClone found (javascript, similar (gap) ~0.91),aiappends(renamed)/[~0.91 gap], JSON addskind,similarityandmethodto each duplicate andrenamedClones/similarClonesto the statistics, XML adds the same attributes, HTML shows a badge, Xcode a suffix, and SARIF and Code Climate use the rulesjscpd/renamed-codeandjscpd/similar-codenext tojscpd/duplicate-code. (#1019, #1021, #1030) - Tips are skipped when stdout is not a terminal — the tips and sponsor lines are printed only on an interactive terminal; a pipe, a file, a CI log or an agent hook no longer receives them.
JSCPD_NO_TIPSjoinsCIas an environment switch and--no-tipsstays the explicit one;NO_COLORonly removes the colours. (#1008, #1029, thanks @7487) - MCP: fully described tool definitions — the four tools now carry a title, read-only annotations, parameter descriptions with examples and defaults, and descriptions that say when to use each tool and what it returns; the server instructions describe the workflow across them. Tool names and schemas are unchanged. (#1028)
Bug Fixes
- Config-file
ignorePatternentries without*or?silently did nothing — such entries were treated as relative paths and joined onto the config directory, so"ignorePattern": ["Copyright 2026 Example Authors"]matched nothing while the same string via--ignore-patternworked. Config entries are now applied verbatim, and an invalid regex prints aWarning:line instead of being dropped silently. Seefixtures/ignore-demo. (#997) - JavaScript/TypeScript files with a recoverable parse error could not match clean files — any parser diagnostic sent the file to the word-split fallback tokenizer, so a file containing, say, a redeclared function was tokenized differently from every well-formed file and never paired with one. Tokens now come from the lexer whenever the parser did not fail outright. Clone counts on codebases with such files change; that is the correction. (#1023, #1024)
- Markdown inherited the C comment style — a
/*(a glob likedocs/**) or//(any URL) in prose opened a comment that swallowed the rest of the file, so two files sharing a paragraph after such a line were never reported. Markdown now has no comment syntax. (#1026, thanks @kwesolowski) - Vue template clones were reported with wrong ranges — the wrapper tags of the file and the template body were appended to the html token stream out of source order, so a clone across the seam took its endpoints from opposite ends of the file. The stream is now in source order, and the wrapper tags (
<template>,<script>,<style>and their closing tags) are left out of it altogether, so a template clone is reported with the template's own line range and the script and style bodies are not counted as duplicated html. Seefixtures/sfc-demo. (#1031, thanks @zero-stroke)
Other
- Runnable demos under
fixtures/— every feature and fix above ships a demo directory (ignore-demo,type2-demo,type3-demo,parse-errors-demo,sfc-demo) whose README lists each command with its expected output, and the same files feed the smoke scan that runs on every pull request. - Docs: ignore patterns and inline markers —
--ignore-pattern/ignorePatternsource-region filtering and thejscpd:ignore-start/jscpd:ignore-endmarkers are documented in the v5 reference, with license-header recipes and a note on the Rust regex syntax. (#993, #996, thanks @w3lld1) - GitHub Action inputs
ignore-identifiers,ignore-literals,ignore-annotations,max-gap-linesandsimilarityfor the features above.
Dependencies
- Add
regex1 to thejscpdcrate for--ignore-patternvalidation (#997) - Bump
taiki-e/install-actionfrom 2.87.2 to 2.87.3 in/.github/workflows(#995)
Thank You ❤️
- @7487 for skipping the tips on a non-terminal stdout (#1029)
- @zero-stroke for the Vue template clone ranges (#1031)
- @kwesolowski for the Markdown comment-style fix (#1026)
- @w3lld1 for documenting ignore patterns and inline markers (#996)
Published Packages
cpd-core@0.1.12on crates.iocpd-finder@0.1.15on crates.iocpd-reporter@0.1.13on crates.iocpd-tokenizer@0.1.14on crates.iojscpd@5.2.0on crates.iocpd@5.2.0on npmjscpd@5.2.0on npmjscpd-darwin-arm64@5.2.0on npmjscpd-darwin-x64@5.2.0on npmjscpd-linux-x64-gnu@5.2.0on npmjscpd-linux-arm64-gnu@5.2.0on npmjscpd-linux-x64-musl@5.2.0on npmjscpd-linux-arm64-musl@5.2.0on npmjscpd-windows-x64-msvc@5.2.0on npmjscpd-windows-arm64-msvc@5.2.0on npm
Verify
Archives are signed with Sigstore (keyless, <asset>.sigstore.json)
and carry SLSA build provenance. Replace jscpd-linux-x64-gnu.tar.gz with your asset:
cosign verify-blob \
--bundle jscpd-linux-x64-gnu.tar.gz.sigstore.json \
--certificate-identity-regexp '^https://github\.com/kucherenko/jscpd/' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
jscpd-linux-x64-gnu.tar.gz
gh attestation verify jscpd-linux-x64-gnu.tar.gz --repo kucherenko/jscpd
sha256sum --check --ignore-missing checksums.txt