{"name":"jscpd","version":"5.3.2","keywords":["jscpd","cpd","copy-paste-detector","duplicate","duplicate-code","code-duplication","duplication","code-quality","static-analysis","dry","sarif","ci","cli","rust"],"license":"MIT","_id":"jscpd@5.3.2","maintainers":[{"name":"apk","email":"kucherenko.andrey@gmail.com"}],"homepage":"https://jscpd.dev","bugs":{"url":"https://github.com/kucherenko/jscpd/issues"},"bin":{"jscpd":"run-jscpd.js"},"dist":{"shasum":"d7b0d6cdcc0c8d011b23f2a84d776e9c3bb58062","tarball":"http://registry-npm.ywwl.com/jscpd/download/jscpd-5.3.2.tgz","fileCount":4,"integrity":"sha512-siYdg3TBNwizWFaYPgr1vwuSs+NWeKJjLAbd00Nkmr2y8TSZRSW0cOGKtqSLgOv7QXDbC/XECnCrZEm5v6RMkg==","signatures":[{"sig":"MEUCIQCfpIlLiCSXMdv4OPnZZei1KGcLujiVitwa2e4z4wrUBQIgdJ2hIzUicqpM/sM9A8lp+kPnUH9naBG3DzivLfeGm8U=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDoVTH6ffn08HDShnvkUqH4oWW4ipOYJPA4SqNz7pI1eAIhALjWhfCGguPwhAMlFZlsL6mQ1mCh0DL7h8V0XKn34E93","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/jscpd@5.3.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":13832,"size":5089,"noattachment":false,"key":"/jscpd/-/jscpd-5.3.2.tgz"},"engines":{"node":">=18"},"funding":"https://opencollective.com/jscpd","gitHead":"beb552864d3342241fbcca0f2c46c6248b0426df","_npmUser":{"name":"apk","email":"kucherenko.andrey@gmail.com"},"repository":{"url":"git+https://github.com/kucherenko/jscpd.git","type":"git","directory":"rust/jscpd"},"_npmVersion":"10.9.8","description":"Copy/paste detector for programming source code. Finds duplicated code in 224 languages, reports as HTML/JSON/SARIF/Markdown, fails CI over a duplication threshold. Rust engine, self-contained binary.","directories":{},"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"optionalDependencies":{"jscpd-darwin-x64":"5.3.2","jscpd-darwin-arm64":"5.3.2","jscpd-linux-x64-gnu":"5.3.2","jscpd-linux-x64-musl":"5.3.2","jscpd-linux-arm64-gnu":"5.3.2","jscpd-linux-arm64-musl":"5.3.2","jscpd-windows-x64-msvc":"5.3.2","jscpd-windows-arm64-msvc":"5.3.2"},"_npmOperationalInternal":{"tmp":"tmp/jscpd_5.3.2_1790162920895_0.5569121727532289","host":"s3://npm-registry-packages-npm-production"},"readme":"# jscpd — Copy/Paste Detector\n\n[![npm version](https://img.shields.io/npm/v/jscpd.svg)](https://www.npmjs.com/package/jscpd)\n[![npm downloads](https://img.shields.io/npm/dm/jscpd.svg)](https://www.npmjs.com/package/jscpd)\n[![license](https://img.shields.io/npm/l/jscpd.svg)](https://github.com/kucherenko/jscpd/blob/master/LICENSE)\n[![crates.io](https://img.shields.io/crates/v/jscpd.svg)](https://crates.io/crates/jscpd)\n[![homepage](https://img.shields.io/badge/homepage-jscpd.dev-blue.svg)](https://jscpd.dev)\n\n> **jscpd v5** is the Rust engine — a self-contained binary, no Node.js runtime. The TypeScript engine (v4: Node.js API, LevelDB/Redis stores) is maintained on the [`master-v4`](https://github.com/kucherenko/jscpd/tree/master-v4) branch and published as `jscpd@4`.\n\nCopy/paste detector for programming source code. Supports **224 language formats**, **15 output reporters**, and per-line author attribution via git blame. Prebuilt binaries for 8 platforms — no Node.js runtime required.\n\n## Packages\n\n| Package | Installs | Use it when |\n|---------|----------|-------------|\n| [`jscpd`](https://www.npmjs.com/package/jscpd) | `jscpd` | Default install; the `jscpd` command |\n| [`cpd`](https://www.npmjs.com/package/cpd) | `cpd` | Shorter command name only |\n| [`jscpd` (crates.io)](https://crates.io/crates/jscpd) | `jscpd` + `cpd` | Rust-native install; both binaries |\n\nThe npm `jscpd` package installs a single `jscpd` command that runs the same Rust binary as `cpd`. For the shorter `cpd` alias on npm, install the separate [`cpd`](https://www.npmjs.com/package/cpd) package.\n\n## Install\n\n```bash\n# npm — installs the jscpd command\nnpm install -g jscpd\n\n# crates.io — installs both jscpd and cpd binaries\ncargo install jscpd\n\n# Nix — run without installing\nnix run github:kucherenko/jscpd -- /path/to/code\n\n# Nix — install permanently\nnix profile install github:kucherenko/jscpd\n\n# Homebrew (macOS/Linux)\nbrew install jscpd\n```\n\nPrebuilt binaries for: macOS arm64/x64, Linux arm64/x64 (glibc + musl), Windows arm64/x64.\n\n## Quick Start\n\n```bash\njscpd .                                       # scan current directory\njscpd ./src ./lib                             # scan specific paths\njscpd . --min-tokens 30 --min-lines 3         # tune detection sensitivity\njscpd . --blame --reporters console-full      # git blame, side-by-side authors\njscpd . --reporters json,html                 # write report files\njscpd . --threshold 10                        # fail CI if >10% duplicated\njscpd --list                                  # list all supported formats\n```\n\n## Options\n\n| Flag | Short | Default | Description |\n|------|-------|---------|-------------|\n| `--min-tokens` | `-k` | 50 | Minimum tokens in a clone |\n| `--min-lines` | `-l` | 5 | Minimum lines in a clone |\n| `--max-lines` | `-x` | — | Maximum lines per duplicate block |\n| `--max-size` | `-z` | — | Skip files larger than SIZE (e.g. `1mb`) |\n| `--mode` | `-m` | `mild` | Detection mode: `mild`, `weak`, `strict` |\n| `--skip-comments` | — | — | Alias for `--mode weak` |\n| `--format` | `-f` | all | Comma-separated formats to check |\n| `--ignore` | `-i` | — | File-level glob patterns to ignore (comma-separated); they match the whole path, so use `**/node_modules/**` for a directory |\n| `--ignore-pattern` | — | — | Code-level regex patterns; tokens overlapping a match are skipped during detection, e.g. `//\\\\s*cpd-disable` (comma-separated) |\n| `--reporters` | `-r` | `console` | Comma-separated reporters |\n| `--output` | `-o` | `report` | Output directory for file reporters |\n| `--config` | `-c` | — | Path to `.jscpd.json` config file |\n| `--threshold` | `-t` | — | Max duplication % before exit 1 |\n| `--blame` | `-b` | — | Enrich clones with git blame data |\n| `--workers` | — | auto | Worker threads for parallel scan |\n| `--skip-local` | — | — | Skip clones within the same directory |\n| `--absolute` | `-a` | — | Use absolute paths in reports |\n| `--silent` | `-s` | — | Suppress console output |\n| `--list` | — | — | List all supported formats and exit |\n\nFull options: [docs/rust.md](https://github.com/kucherenko/jscpd/blob/master/docs/rust.md).\n\n## Reporters\n\n| Reporter | Output |\n|----------|--------|\n| `console` | Clone list + statistics table (default) |\n| `console-full` | Source snippets; with `--blame` shows side-by-side author comparison |\n| `json` | `report/jscpd-report.json` |\n| `html` | `report/jscpd-report.html` |\n| `sarif` | `report/jscpd-report.sarif` (GitHub Code Scanning) |\n| `ai` | Token-efficient output for LLM pipelines |\n| `badge` | `report/jscpd-badge.svg` + `report/jscpd-lines-badge.svg` |\n\nAlso: `xml`, `csv`, `markdown`, `codeclimate`, `openmetrics`, `xcode`, `threshold`, `silent` (15 total).\n\n## Config File\n\nCreate `.jscpd.json` in your project root:\n\n```json\n{\n  \"minTokens\": 30,\n  \"minLines\": 3,\n  \"format\": [\"javascript\", \"typescript\", \"python\"],\n  \"ignore\": [\"**/node_modules/**\", \"**/dist/**\", \"**/*.min.js\"],\n  \"reporters\": [\"console\", \"json\"],\n  \"output\": \"report\",\n  \"threshold\": 5,\n  \"blame\": false\n}\n```\n\n## Supported Formats\n\n224 formats including: JavaScript, TypeScript, Python, Go, Rust, Java, C/C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Vue SFC, Svelte, Astro, Markdown, SQL, HTML, CSS, Bash, Dart, Lua, R, Haskell, Clojure, Elixir, Apex, CFML, and 200+ more.\n\nRun `jscpd --list` for the full list, or see [FORMATS.md](https://github.com/kucherenko/jscpd/blob/master/FORMATS.md).\n\n**Cross-format detection:** Vue SFC (`.vue`), Svelte (`.svelte`), Astro (`.astro`), and Markdown files are tokenized per-block, enabling duplicate detection across file types.\n\n## CI\n\nGitHub Action — installs the Rust engine, runs detection, uploads SARIF to GitHub Code Scanning:\n\n```yaml\n- uses: kucherenko/jscpd@v5\n  with:\n    threshold: 5\n```\n\nPre-commit hook (Husky):\n\n```bash\necho 'npx jscpd --threshold 5 --reporters console,silent .' > .husky/pre-commit\n```\n\nFull CI/pre-commit guide: [docs/ci-and-hooks.md](https://github.com/kucherenko/jscpd/blob/master/docs/ci-and-hooks.md).\n\n## Programmatic Usage (Rust)\n\n```rust\nuse cpd_finder::orchestrate::{RunConfig, run};\n\nlet config = RunConfig {\n    paths: vec![\"./src\".into()],\n    min_tokens: 50,\n    ..Default::default()\n};\n\nlet result = run(&config).unwrap();\nprintln!(\"Found {} clones\", result.clones.len());\nprintln!(\"Analyzed {} files\", result.statistics.total.sources);\n```\n\n## Coming from jscpd v4\n\nFlags, config file and reporters are the same. The differences:\n\n| Feature | jscpd v4 (Node.js) | jscpd v5 (Rust) |\n|---------|--------------------|-----------------|\n| `--store` (LevelDB/Redis) | Persistent store for large repos | Not supported (flag ignored with a warning) |\n| Programming API | `jscpd()` Promise, `detectClones()` | Rust crate API; no Node.js API |\n| `--reporters` | All v4 reporters | All except `full` (use `console-full`) |\n| Output filenames | `jscpd-report.json`, `html/` dir | `jscpd-report.*` prefix |\n\nFull table: [docs/rust.md](https://github.com/kucherenko/jscpd/blob/master/docs/rust.md#migrating-from-jscpd-v4). jscpd v4 lives on the [`master-v4`](https://github.com/kucherenko/jscpd/tree/master-v4) branch.\n\n## Architecture\n\n```\njscpd (CLI binary)\n ├── cpd-core      — Detection algorithm (Rabin-Karp rolling hash)\n ├── cpd-tokenizer — Language tokenization (224 formats)\n ├── cpd-finder    — File walking, orchestration, git blame\n └── cpd-reporter  — Output formatting (15 reporters)\n```\n\n## Links\n\n- [Homepage](https://jscpd.dev)\n- [Documentation](https://github.com/kucherenko/jscpd/blob/master/docs/rust.md)\n- [FORMATS.md — all 224 formats](https://github.com/kucherenko/jscpd/blob/master/FORMATS.md)\n- [Benchmark vs other tools](https://github.com/kucherenko/jscpd/blob/master/benchmark/BENCHMARK.md)\n- [AI reporter, MCP server](https://github.com/kucherenko/jscpd/blob/master/docs/ai-ready.md)\n- [GitHub](https://github.com/kucherenko/jscpd)\n- [Changelog](https://github.com/kucherenko/jscpd/blob/master/rust/CHANGELOG.md)\n\n## License\n\nMIT\n","publish_time":1790162920977,"_cnpm_publish_time":1790162920977,"dist-tags":{"canary":"3.3.0-alpha.8","latest":"5.4.2","latest-4":"4.3.0","prerelease":"1.0.0-rc.6","rc":"4.0.0"}}