> ## Documentation Index
> Fetch the complete documentation index at: https://docs.safedep.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Path Exclusion

> Exclude specific directories and files from security scans using pattern matching

`vet` supports path exclusions when scanning a directory: use the `--exclude` flag to skip path patterns within the target. Path exclusions are available only for the `scan` command.

## Basic Usage

Exclude a single path pattern during directory scanning:

```bash theme={null}
vet scan -D /path/to/target --exclude 'docs/*'
```

## Multiple Exclusions

Specify multiple path patterns for exclusion:

```bash theme={null}
vet scan -D /path/to/target \
    --exclude 'docs/*' \
    --exclude 'sub/dir/path/*' \
    --exclude '*.test.js'
```

<Info>
  Exclusion patterns use [glob matching](https://github.com/bmatcuk/doublestar) (the `doublestar` library), not regular expressions. Use `*` to match within a single path segment and `**` to match across directories.
</Info>

## Common Exclusion Patterns

### Documentation and Build Artifacts

```bash theme={null}
vet scan -D . \
    --exclude 'docs/*' \
    --exclude 'build/*' \
    --exclude 'dist/*' \
    --exclude 'target/*' \
    --exclude '*.generated.*'
```

### Test Files and Directories

```bash theme={null}
vet scan -D . \
    --exclude 'test/*' \
    --exclude 'tests/*' \
    --exclude '*_test.go' \
    --exclude '*.test.js' \
    --exclude 'spec/*'
```

### Version Control and Dependencies

```bash theme={null}
vet scan -D . \
    --exclude '.git/*' \
    --exclude 'node_modules/*' \
    --exclude 'vendor/*' \
    --exclude '.venv/*' \
    --exclude '__pycache__/*'
```

### Development Tools

```bash theme={null}
vet scan -D . \
    --exclude '.idea/*' \
    --exclude '.vscode/*' \
    --exclude '*.log' \
    --exclude 'tmp/*' \
    --exclude 'temp/*'
```

## Advanced Pattern Examples

### File Extension Exclusions

```bash theme={null}
# Exclude specific file types
vet scan -D . \
    --exclude '**/*.md' \
    --exclude '**/*.txt' \
    --exclude '**/*.png' \
    --exclude '**/*.jpg'
```

### Environment-Specific Exclusions

```bash theme={null}
# Development environment
vet scan -D . \
    --exclude 'dev-tools/**' \
    --exclude 'local-config/**' \
    --exclude '**/*.dev.*'

# Production build
vet scan -D . \
    --exclude 'test/*' \
    --exclude 'examples/*' \
    --exclude 'dev-dependencies/*'
```

### Complex Pattern Matching

```bash theme={null}
# Exclude multiple similar patterns
vet scan -D . \
    --exclude '**/test/**' \
    --exclude '**/tests/**' \
    --exclude '**/spec/**' \
    --exclude '**/mocks/**'
```

## Makefile Integration

```makefile theme={null}
# Makefile with different scan targets
.PHONY: scan-prod scan-dev scan-all

scan-prod:
	vet scan -D . \
		--exclude 'test/*' \
		--exclude 'dev-tools/*' \
		--exclude 'docs/*' \
		--report-json production-scan.json

scan-dev:
	vet scan -D . \
		--exclude 'node_modules/*' \
		--exclude '.git/*' \
		--report-json development-scan.json

scan-all:
	vet scan -D . \
		--exclude '.git/*' \
		--report-json complete-scan.json
```
