Skip to content

Exclusions

When exclusions ship, they will be configured as a list of glob patterns under an exclude key in nolapse.yaml:

# Planned — not yet supported
lang: go
warn_threshold: -1.0
fail_threshold: -3.0
exclude:
- "**/*_generated.go"
- "internal/testdata/**"
- "vendor/**"

Patterns will follow standard glob syntax. Matched files will be omitted from the coverage calculation before nolapse compares against the baseline.

Until exclusions are implemented, you can exclude files at the coverage tool level rather than at the nolapse level.

Use a build tag to prevent test files or generated files from being instrumented:

//go:build ignore

Or use -coverpkg to limit which packages are measured:

Terminal window
go test -coverpkg=./internal/...,./pkg/... ./...

You can also exclude specific packages by listing only the ones you want:

Terminal window
go test -coverprofile=coverage.out $(go list ./... | grep -v '/vendor/' | grep -v '/generated/')

After generating a coverage profile, strip unwanted lines before nolapse reads it:

Terminal window
go test -coverprofile=coverage.out ./...
grep -v "_generated.go" coverage.out > coverage.filtered.out

Then point nolapse at the filtered profile (exact flag name subject to change in future releases — check nolapse run --help).

Use pytest --ignore to exclude directories from test collection and coverage measurement:

Terminal window
pytest --cov=src --ignore=src/generated --ignore=tests/fixtures

Or add persistent ignores to pytest.ini / pyproject.toml:

pytest.ini
[pytest]
addopts = --ignore=src/generated
pyproject.toml
[tool.pytest.ini_options]
addopts = "--ignore=src/generated"

Use .coveragerc to omit paths from coverage reporting:

.coveragerc
[run]
omit =
src/generated/*
tests/fixtures/*
**/conftest.py

Or in pyproject.toml:

[tool.coverage.run]
omit = [
"src/generated/*",
"tests/fixtures/*",
]

The exclusions feature is tracked as a P1 item on the nolapse roadmap. When it ships, the exclude key will be added to the nolapse.yaml schema and this page will be updated with the full reference.