实时重复代码分析
查找重复代码 覆盖整个代码库。
查找重复代码、比较副本,确定优先移除的部分。在 VS Code 中实时运行,并连接你的编码智能体。
一个扩展即可获得实时编辑器警告、面向编码智能体的 MCP 检查和 CLI。
-
01 · 查找
最严重的问题优先
影响最大的重复代码簇始终排在顶部。
-
02 · 查看
查看每个副本
打开代码簇,查看出现位置和规范副本。
-
03 · 比较对比
规范副本比较
重构前并排检查两个副本。
语言
在 C#、Python、Rust、TypeScript、Go 等语言中查找重复代码。
重复代码是指同一逻辑被写了不止一次,即使名称和字面量不同。Deslop 把每个文件解析成语法树,所以即使每个变量都改了名,也能找到副本。它还会在 Claude Code、Cursor 等编码智能体写出另一个副本之前,告诉它们已有相似代码。
- Osprey .osp .ospml
- C# .cs
- Rust .rs
- Python .py
- Dart .dart
- JavaScript .js .mjs .cjs .jsx
- TypeScript .ts
- TSX .tsx
- F# .fs .fsx
- PHP .php
- Go .go
- C .c .h
orders.pydef order_total(orders, tax_rate):
subtotal = sum(order.price * order.quantity for order in orders)
discount = subtotal * 0.1 if subtotal > 100 else 0
return round((subtotal - discount) * (1 + tax_rate), 2)
invoices.pydef invoice_total(lines, vat):
net = sum(line.cost * line.units for line in lines)
rebate = net * 0.2 if net > 500 else 0
return round((net - rebate) * (1 + vat), 2)
- 解析 每个文件变成一棵语法树。
- 归一化 抹去名称与字面量。
- 匹配 形状相同,指纹相同。
- 排序 最大的重复排在最前。
Deslop 将这两个函数报告为一个簇:两个几乎相同的副本。
实地反馈
可以直接合并的发现。
-
Holy cow dude! My initial analysis of this tool, I am blown away and super excited.
Kevin Moore Google Dart 与 Flutter 产品经理 @kevmoo · 2026-08-05 -
I gave Claude Code a hook it was about to write, and find-similar pointed it straight at the existing copy. That's the "don't write a third one" loop I want in every agent session.
John Kattenhorn 公司、团队与系统的构建者 @johnjkattenhorn · 2026-11-14 在他 6.1 万行的 TypeScript 与 Python monorepo 上运行:
- 341 files in about 6 seconds, ranked worst first, with HTML, JSON and text reports.
- One response-handling block was copied across three API routes, and one data-polling hook was copied in two views. Both fold into a single function.
- It found something the plain scan couldn't: two versions of the same git helper in two different reporters, written in different styles.
安装
在你的编辑器中安装 Deslop。
从 Visual Studio Marketplace 或 Open VSX 安装同一个扩展。
-
Visual Studio Marketplace
VS Code · GitHub Codespaces
完整捆绑包——实时气泡、LSP 服务器、MCP 服务器与 deslop CLI——适用于 VS Code 与 GitHub Codespaces。
-
Open VSX Registry
Cursor · Windsurf · VSCodium
同一扩展,适用于 Cursor、Windsurf、VSCodium、Gitpod 以及所有 Open VSX 编辑器。