Excluding Files from Coverage
There are two ways to exclude files from coverage in Qlty:
- In your coverage tool — exclude files before the coverage report is generated
- In
qlty.toml— filter files out of coverage data during upload
If you use other coverage tools or dashboards alongside Qlty, configuring exclusions in your coverage tool keeps your coverage data consistent everywhere. If Qlty is where you manage coverage, either approach works — qlty.toml is often the simpler option.
Excluding files in your coverage tool
Each coverage tool has its own configuration for excluding files. Below are examples for common tools.
JavaScript / TypeScript (Jest / Istanbul)
Configure coverage exclusions in your Jest config (jest.config.js or package.json):
collectCoverageFrom: Specify which files to include (use!to exclude patterns)coveragePathIgnorePatterns: Exclude files matching these patterns
If using NYC (Istanbul) directly, configure in .nycrc or package.json:
Python (pytest-cov / coverage.py)
Configure exclusions in your pyproject.toml, setup.cfg, or .coveragerc:
Or in .coveragerc:
You can also exclude specific lines or blocks using inline comments:
Ruby (SimpleCov)
Configure exclusions in your test helper where SimpleCov is initialized:
add_filter accepts strings, regex patterns, or blocks.
Java / Kotlin (JaCoCo)
Configure exclusions in your build file.
Gradle:
Maven:
Go
Go’s built-in coverage tool uses build tags and package patterns to control coverage scope:
PHP (PHPUnit)
Configure coverage exclusions in phpunit.xml:
Swift (Xcode / Slather)
When using Slather, configure exclusions in .slather.yml:
When using xccov, exclusions must be configured at the Xcode scheme level or by post-processing the coverage data before uploading.
Elixir (lcov_ex)
In Elixir, configure which modules to exclude from coverage in mix.exs:
Excluding files in qlty.toml
You can also exclude files from coverage using the [coverage].ignores setting in qlty.toml. When qlty coverage publish runs, any file path in the coverage report that matches an ignore pattern is dropped before uploading.
Built-in default exclusions
Qlty applies a set of default exclude_patterns that automatically propagate to coverage ignores. These include paths like:
Any patterns you add to [coverage].ignores are combined with these defaults.
Using exclude_patterns for coverage
The top-level exclude_patterns setting in qlty.toml automatically propagates to [coverage].ignores. This means any pattern in exclude_patterns also excludes files from coverage.
Using exclude_patterns for coverage exclusions is deprecated. Use [coverage].ignores for coverage-specific exclusions instead.
Removing missing files
If your coverage report contains paths for files that don’t exist on disk (e.g., generated during CI but not checked in), you can drop them during upload:
Common files to exclude
Depending on your project, you may want to exclude:
- Generated code: API clients, protobuf files, GraphQL types
- Vendor/third-party code: Dependencies copied into your repository
- Configuration files: Setup, bootstrap, or configuration modules
- Migration files: Database migration scripts
- Test utilities: Test helpers, fixtures, and factories
See Also
- Generating Coverage Data for language-specific setup
- Excluding Files from Analysis for static analysis exclusions (separate from coverage)
- Unexpected Coverage Changes for troubleshooting coverage differences