Status: This project is ARCHIVED as of January 14, 2026 Action: Please migrate to art-dupl - all functionality is now available there
This repository has been archived because all functionality has been successfully merged into the more feature-rich art-dupl project.
- Complete feature parity: Every feature from
duplicatesis now inart-dupl - Enhanced capabilities:
art-duploffers many additional features (config files, sorting, filtering, etc.) - Better performance: Improved LineIndex implementation with binary search
- More mature:
art-duplhas professional CLI (cobra/fang), auto-completion, and comprehensive testing - Single tooling: Consolidates duplicate detection into one maintained project
✅ All duplicates features:
- Token-sequence detection
- Configurable threshold
- Multiple output formats (JSON, HTML, Text, Plumbing)
- Line number tracking
- Scoring system (tokens × instances)
- File exclusion patterns
- Fast AST-based scanning
✅ Plus enhancements:
- Simple JSON format (
--simple-json) - Exact format match with duplicates - Enhanced JSON format (
--json) - Rich metadata and statistics - Multiple sorting options - Sort by size, occurrence, hash
- Config file support - Team consistency with JSON/YAML config
- Auto-generated code filtering - Ignore sqlc, templ, etc.
- Professional CLI - Auto-completion, version info, man pages
- Performance profiling - Identify bottlenecks
- Multiple detection methods - Suffix tree and hash-based
# Install from source
git clone https://github.com/LarsArtmann/art-dupl.git
cd art-dupl
make build
# Or via Go
go install github.com/LarsArtmann/art-dupl@latest# Old (duplicates):
duplicates -threshold 20 -json report.json -html report.html
# New (art-dupl):
art-dupl --simple-json > report.json
art-dupl --html > report.html
# Or generate all at once:
art-dupl --all --output-dir ./reports --threshold 20| duplicates Flag | art-dupl Flag | Notes |
|---|---|---|
-threshold N |
--threshold N or -t N |
Same functionality |
-json report.json |
--simple-json > report.json |
Use redirection or --output-dir |
-html report.html |
--html > report.html |
Use redirection or --output-dir |
-text report.txt |
default (no flag) | Text is default, use > to redirect |
-plumbing |
--plumbing |
Same functionality |
-v |
--verbose or -v |
Same functionality |
-exclude "pattern" |
--exclude-pattern "pattern" |
More powerful patterns |
Replace these patterns in your pipelines:
# Old:
- run: duplicates -threshold 30 -json report.json
# New:
- run: art-dupl --simple-json --threshold 30 > report.jsonA fast and accurate code duplicate detection tool for Go codebases. Find repeated code blocks, identify technical debt, and improve code maintainability.
- Token-sequence based detection - Finds structural duplicates, not just textual matches
- Configurable threshold - Adjust sensitivity based on your needs
- Multiple output formats - JSON, HTML, Text, and Plumbing reports
- Line number tracking - Precise location of each duplicate instance
- Scoring system - Prioritize duplicates by impact (tokens × instances)
- File exclusion patterns - Ignore test files, generated code, etc.
- Fast scanning - Efficient AST-based analysis
IMPORTANT: This project is archived. Please install art-dupl instead.
# Install from source
git clone https://github.com/LarsArtmann/art-dupl.git
cd art-dupl
make build
# Or via Go
go install github.com/LarsArtmann/art-dupl@latestFor legacy reasons only. All features now in art-dupl.
go install github.com/larsartmann/duplicates/cmd/duplicates@latestOr build from source:
git clone https://github.com/larsartmann/duplicates.git
cd duplicates
go build -o duplicates ./cmd/duplicatesScan the current directory for duplicates:
duplicatesSet the minimum token sequence size (default: 15):
duplicates -threshold 20Lower values = more sensitive (finds smaller duplicates) Higher values = less sensitive (only finds significant duplicates)
Ignore specific file patterns:
duplicates -exclude "*_test.go,generated.go,mock_*.go"Generate reports in multiple formats simultaneously:
duplicates -json report.json -html report.html -text report.txtSee what's happening during the scan:
duplicates -vSpecify output paths:
duplicates -json ./reports/duplicates.json -html ./reports/overview.html| Flag | Default | Description |
|---|---|---|
-threshold |
15 | Minimum token sequence size to consider as duplicate |
-exclude |
"" | Comma-separated file patterns to exclude |
-json |
"reports/duplicates.json" | Path to JSON report |
-html |
"reports/duplicates.html" | Path to HTML report |
-text |
"reports/duplicates.txt" | Path to Text report |
-plumbing |
"reports/duplicates.plumbing" | Path to Plumbing report |
-v |
false | Verbose output |
Machine-readable format with full details:
[
{
"hash": "abc123...",
"score": 150,
"instances": [
{
"filename": "internal/service/user.go",
"start_line": 45,
"end_line": 78,
"token_count": 50
},
{
"filename": "internal/service/product.go",
"start_line": 23,
"end_line": 56,
"token_count": 50
}
]
}
]Interactive HTML report with syntax highlighting and navigation. Open in your browser to explore duplicates visually.
Human-readable summary:
Duplicate Group #1 (Score: 150)
internal/service/user.go:45-78
internal/service/product.go:23-56
Simple, parseable format for scripting:
hash\tfilename\tstart_line\tend_line\ttoken_count
Score = Token Count × Number of Instances
Higher scores indicate:
- More duplicated code (more tokens)
- More widespread duplication (more instances)
Use scores to prioritize refactoring efforts.
The -threshold value determines what counts as a duplicate:
- 10-15: Small helper functions, validation logic
- 20-30: Business logic, medium-sized functions
- 40+: Large functions, complex algorithms
- Code review: Identify and eliminate duplicates before merging
- Refactoring: Prioritize technical debt reduction
- CI/CD: Fail builds if duplicate score exceeds threshold
- Architecture review: Find opportunities for abstraction
- Onboarding: Help new developers understand codebase structure
-
Initial scan:
duplicates -threshold 20 -html report.html
-
Review results: Open
report.htmlin your browser -
Prioritize: Focus on groups with the highest scores
-
Refactor: Extract common code to shared utilities
-
Verify: Re-run to confirm duplicates are eliminated
IMPORTANT: This repository is archived. Development continues in art-dupl.
For legacy maintenance of this archived project:
# Run tests
go test ./...
# Build
go build ./cmd/duplicates
# Lint
golangci-lint runFor new features and bug fixes, please contribute to art-dupl.
Status: Development has moved to art-dupl
The following features are now available in art-dupl:
- Fail threshold (exit code 1 if score exceeds limit) - Available in art-dupl
- Config file support - Available in art-dupl (
--config dupl.json) - Concurrent file scanning - Available in art-dupl
- stdin input support for file lists - Available in art-dupl (
--files) - Multiple sorting options - Available in art-dupl (
--sort) - Filter auto-generated code - Available in art-dupl (
--filter-generated) - Performance profiling - Available in art-dupl (
--profile) - Language-agnostic mode - Not yet planned
Recommendation: Use art-dupl for all future features.
[Add your license here]
This repository is archived - Please contribute to art-dupl instead.
This repository is maintained in read-only mode for historical purposes. All new features, bug fixes, and improvements should be made to art-dupl, which contains all functionality from this project plus many enhancements.
Archived: January 14, 2026 Successor: art-dupl Reason: Complete feature parity achieved
Built with golangci/dupl algorithm