convez.ai
PluginDevOps & InfraestruturaIntermediário
kucherenko

jscpd - Detector de Código Duplicado

kucherenko/jscpd

Detecta duplicação de código em 223+ formatos com motor Rust ultrarrápido

Ver no GitHub
Muito bomPluginScore · de 0 a 100

Ferramenta de análise estática que detecta blocos de código duplicados e copy/paste em 223+ formatos de linguagem de programação. Implementa o algoritmo Rabin-Karp com motor Rust 24-37x mais rápido que a versão anterior. Oferece MCP server pronto para IA com reporter otimizado em tokens.

Instalação

$npx convez-ai kucherenko/jscpd

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
6,6 mil
Forks
276
Acompanhando
26
Saúde
85%
Último commit
há 1 dia
Versão
v5.4.3
Issues abertas
62
Contribuidores
71

Casos de uso

  • Análise de qualidade de código em repositórios grandes
  • Detecção de violações de DRY (Don't Repeat Yourself) antes de merge
  • Integração com pipelines CI/CD para verificar código duplicado
  • Refatoração assistida por IA com relatórios otimizados para LLMs

Veredito

Ferramenta madura e bem mantida para detecção de duplicação de código com suporte excepcional a múltiplas linguagens. A versão Rust (v5) representa um avanço real em performance, adequada para análise de bases de código grandes em pipelines automatizados.

README

A tradução para o português deste README ainda está na fila.

jscpd

stand with Ukraine

npm jscpd license npm

jscpd CI codecov FOSSA Status Backers on Open Collective Sponsors on Open Collective

NPM

Copy/paste detector for programming source code. Supports 224+ formats. AI-ready with MCP server and token-efficient reporter. Now with a Rust-powered engine — 24-37x faster.

jscpd implements the Rabin-Karp algorithm to find duplicated code blocks across files.

Quick Start

# TypeScript engine (Node.js, v4.x)
npm install -g jscpd@4
jscpd /path/to/code
# or use without installing
npx jscpd@4 /path/to/code

# Rust engine (v5.x, 24-37x faster) — both jscpd and cpd commands
npm install -g jscpd@5
jscpd /path/to/code
cpd /path/to/code

# Rust engine — cpd command only
npm install -g cpd
cpd /path/to/code

# Rust-native install (exposes both jscpd and cpd)
cargo install jscpd

Documentation

DocumentDescription
TypeScript (v4.x)Node.js engine — CLI, reporters, config, detection modes
Rust (v5.x)Rust engine — installation, CLI, reporters, blame, Rust API
AI-ReadyAI reporter, agent skills, MCP server
Programming APITypeScript and Rust programmatic APIs
PackagesMonorepo package and crate overview

Two Engines

TypeScript (v4)Rust (v5)
npm packagejscpd@4jscpd@5 or cpd
CLI commandjscpdjscpd and cpd (both available)
SpeedBaseline24-37x faster
Formats224223
Node.js requiredYesNo (self-contained binary)
Programming APITypeScript (jscpd(), detectClones())Rust (cpd-finder crate)
LevelDB storeYesNo
Reporters1313

jscpd@5 installs both jscpd and cpd commands. The cpd npm package installs only the cpd command. Both contain the same Rust binary.

What's New

v5.0.x — Rust Engine

jscpd v5 is a ground-up Rust rewrite that ships as jscpd@5 (installs both jscpd and cpd commands) or cpd (installs the cpd command only). Self-contained binary — no Node.js runtime required.

Same interface, 24-37x faster:

  • All CLI options from v4 are preserved — drop-in replacement: jscpd → jscpd@5
  • Same .jscpd.json config file, same detection algorithm, same reporters
  • 223 language formats with cross-format detection (Vue SFC, Svelte, Astro, Markdown)

New in v5:

  • 24-37x faster detection on real projects (see benchmark)
    • Small codebases (548 files): 34x faster
    • Medium codebases (9K files): 37x faster
    • Large codebases (17K files, 900 MB): 24x faster
  • Git blame with side-by-side author comparison (--blame --reporters console-full) — uses gitoxide instead of shelling out to git, making blame significantly faster
  • --workers — control parallelism for file tokenization and detection (default: auto, uses all CPU cores; not available in v4)
  • 13 reporters: console, console-full, json, xml, csv, html, markdown, badge, sarif, ai, xcode, threshold, silent
  • AI reporter — token-efficient output for LLM pipelines (~79% fewer tokens than console)
  • Self-contained binary — prebuilt for 6 platforms (macOS arm64/x64, Linux arm64/x64, Windows x64)

Not yet in v5 (use v4 for these):

  • LevelDB/Redis stores (--store leveldb)
  • Node.js programming API (jscpd(), detectClones())

See Rust docs for the full CLI reference and differences from v4.

v4.2.x — TypeScript Engine

  • Custom tokenizer backend — replaced prismjs with own backend built on reprism. ~11.5% faster tokenization on real projects
  • Cross-format detection — Vue SFC, Svelte, Astro, and Markdown tokenized per-block, enabling detection across file types
  • New formats: Apex, CFML/ColdFusion, GDScript, and 70+ additional formats (224 total, up from 152)
  • Shebang detection — auto-detect language for extensionless scripts
  • --store-path — configure LevelDB cache directory for parallel runs
  • --skipComments — shorthand for --mode weak
  • --formats-names — map filenames (e.g. Makefile, Dockerfile) to formats
  • --noTips — suppress tip output in CI
  • Bug fixes: entire-file duplicates silently dropped (#728), ReDoS on Lisp/Elisp files (#737), process crash on malformed package.json (#739), Vue SFC cross-file detection (#737), Vue SFC column numbers (#737), 50 dependency security vulnerabilities

See TypeScript docs for the full CLI reference.

Packages

PackageDescription
jscpdCLI and Node.js API (v4.x)
jscpd-serverREST API + MCP server
@jscpd/coreCore detection algorithm
@jscpd/finderFile detection, reporters
@jscpd/tokenizerSource code tokenization
@jscpd/html-reporterHTML report
@jscpd/badge-reporterSVG badge
jscpd-sarif-reporterSARIF (GitHub Code Scanning)
@jscpd/leveldb-storeLevelDB persistent store
@jscpd/redis-storeRedis distributed store
cpd (Rust engine)Rust-powered engine (v5.x) — also available as jscpd@5

Who Uses jscpd

Performance

Benchmarked on macOS (Apple Silicon), 10 runs per target (3 for CopilotKit). v4 ran with --no-gitignore -i "node_modules" to ensure comparable file scanning.

TargetFilesSizejscpd v4jscpd v5Speedup
fixtures5481.5 MB1.03s0.03s34.3x
svelte9K38 MB15.80s0.43s36.9x
CopilotKit17K159 MB82.89s3.44s24.1x

See performance-comparison.md for full methodology and raw data.

Contributing

  1. Fork the repo kucherenko/jscpd
  2. Clone forked version (git clone https://github.com/{your-id}/jscpd)
  3. Install dependencies (pnpm install)
  4. Run in dev mode: pnpm dev
  5. Add your changes
  6. Add tests and check: pnpm test
  7. Build: pnpm build
  8. Create PR

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

ga tracker

Star History

Star History Chart

License

MIT © Andrey Kucherenko

Ver o original no GitHub

Bom para

Relacionados