Skip to content

Smart Filtering

art-dupl automatically filters generated code by default. This removes noise from:

  • sqlc — SQL-to-Go code generator
  • templ — Templ-generated *_templ.go files
  • protobuf.pb.go, _grpc.pb.go files
  • mockgen — Mock generation framework
  • stringer — String method generation
  • generic — Any file with a “Code generated by” comment

Include specific generated categories with --include-generated:

Terminal window
art-dupl --include-generated sqlc # Include sqlc-generated
art-dupl --include-generated templ,protobuf # Multiple categories
art-dupl --include-generated all # Everything

Available categories: sqlc, templ, protobuf, mockgen, stringer, generic, all.

--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.

Terminal window
art-dupl --only go # .go files only
art-dupl --only templ # .templ files only

By default, both .go and .templ files are analyzed.

Terminal window
art-dupl --include-pattern "internal/*" # Include specific paths
art-dupl --exclude-pattern "*_test.go" # Exclude test files
art-dupl --exclude-pattern "vendor/*" # Exclude vendor (default)

Multiple patterns can be specified by repeating the flag.

By default, these directories are excluded:

  • vendor/
  • .git/
  • node_modules/

Include them with:

Terminal window
art-dupl --vendor # Include vendor directory
art-dupl --include-node-modules # Include node_modules (hash detection)

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.

Terminal window
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.