Smart Filtering
Generated Code Filtering
Section titled “Generated Code Filtering”art-dupl automatically filters generated code by default. This removes noise from:
- sqlc — SQL-to-Go code generator
- templ — Templ-generated
*_templ.gofiles - protobuf —
.pb.go,_grpc.pb.gofiles - mockgen — Mock generation framework
- stringer — String method generation
- generic — Any file with a “Code generated by” comment
Override Filters
Section titled “Override Filters”Include specific generated categories with --include-generated:
art-dupl --include-generated sqlc # Include sqlc-generatedart-dupl --include-generated templ,protobuf # Multiple categoriesart-dupl --include-generated all # EverythingAvailable categories: sqlc, templ, protobuf, mockgen, stringer, generic, all.
Filter Override Behavior
Section titled “Filter Override Behavior”--include-generated sqlc disables FilterSQLC but the generic filter (any “Code generated by” comment) still catches the file unless it was explicitly included. The shouldIncludeFile function in cmd/util.go handles this logic.
File Type Filtering
Section titled “File Type Filtering”art-dupl --only go # .go files onlyart-dupl --only templ # .templ files onlyBy default, both .go and .templ files are analyzed.
Custom Patterns
Section titled “Custom Patterns”art-dupl --include-pattern "internal/*" # Include specific pathsart-dupl --exclude-pattern "*_test.go" # Exclude test filesart-dupl --exclude-pattern "vendor/*" # Exclude vendor (default)Multiple patterns can be specified by repeating the flag.
Directory Exclusions
Section titled “Directory Exclusions”By default, these directories are excluded:
vendor/.git/node_modules/
Include them with:
art-dupl --vendor # Include vendor directoryart-dupl --include-node-modules # Include node_modules (hash detection)Actionability Filtering
Section titled “Actionability Filtering”art-dupl automatically suppresses clone groups that represent Go boilerplate rather than real duplication:
- Signature-only clones
- Interface implementations
- RAII defer patterns
- Error propagation (
err := ...; if err != nil { return ... }) - Test data pairs
- Table-driven test scaffolding
- Data-dominated blocks
- Builder callback patterns
- Cobra CLI boilerplate
- Assertion chains
- Single call expressions
- Assign + error check
A group is marked NonActionable only when EVERY clone matches the same boilerplate pattern. These are still counted in statistics but suppressed from default output.
Test File Threshold
Section titled “Test File Threshold”art-dupl --test-threshold 20 # Separate threshold for test files (0 = max(30, threshold))Test files often have legitimate repetition. The test threshold defaults to max(30, threshold) to reduce noise.