Skip to content

feat: support ** recursive glob patterns in --exclude #15

Closed

Description

@machado144

Problem

--exclude currently uses filepath.Match (shell glob), which does not support ** recursive matching. This means you cannot exclude nested directories like vendor/, node_modules/, or dist/ without specifying exact paths.

# This does NOT work today — no recursive match
dupehound scan --exclude "vendor/**" --exclude "node_modules/**"

# Workaround is painful and incomplete
dupehound scan --exclude "vendor/*" --exclude "node_modules/*"

For real-world codebases (Go modules, JS monorepos, generated code dirs), this is a blocking gap for adopting dupehound in CI.

Proposed behavior

Support ** in --exclude patterns using doublestar or equivalent:

# Exclude entire directory trees
dupehound scan --exclude "vendor/**" --exclude "node_modules/**"

# Exclude generated files anywhere in the tree
dupehound scan --exclude "**/*.pb.go" --exclude "**/*_generated.go"

# Exclude a nested test fixtures dir
dupehound scan --exclude "**/testdata/**"

Same syntax should apply to exclude: in .dupehound.yml:

scan:
  path: .
  exclude:
    - "vendor/**"
    - "node_modules/**"
    - "**/*.pb.go"
    - "**/testdata/**"

Expected output (before fix)

# vendor/ files appear in results even when excluded
dupehound scan --exclude "vendor/**"
Files scanned : 842 / 1200    ← vendor files still scanned

Expected output (after fix)

dupehound scan --exclude "vendor/**"
Files scanned : 358 / 1200    ← vendor subtree fully excluded

Backward compatibility

  • Existing patterns without ** (e.g., *.go, *_test.go) must continue to work identically — filepath.Match semantics are preserved for non-** patterns.
  • Only the addition of ** support is new behavior.
  • No flag changes, no config schema changes.

Activity

  1. added 5 commits that reference this issue on Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址