Path Fixing
Coverage reports often contain file paths that don’t match your repository structure. This can happen when tests run in different environments (Docker containers, CI runners, different operating systems), when using monorepos or when coverage tools generate absolute paths. Qlty provides path fixing options to resolve these mismatches.
Common Path Issues
Absolute Paths
Coverage tools often generate absolute paths that include the full filesystem path or more than the root relative path:
These should be relative to your repository root:
Container Paths
When running tests in Docker containers, paths often include the container’s working directory:
Missing Path Prefixes
Sometimes coverage reports have paths that are missing required prefixes, particularly in case of monorepos or nested projects:
Jacoco
Some Jacoco projects generate coverage with missing path prefixes where a single path prefix will not suffice. See Using JACOCO_SOURCE_PATH.
Path Fixing Options
Strip Prefix
Remove unwanted prefixes from file paths using --strip-prefix:
Add Prefix
Add required prefixes to file paths using --add-prefix:
Combining Options
You can use both --strip-prefix and --add-prefix together:
Using JACOCO_SOURCE_PATH
Java projects with multiple modules often generate coverage for each module with source code paths relative to their module, leaving out its parent directories.
For example, a multi-module Maven project might have source code located in:
But the resulting jacoco.xml may not includes these directories when listing source code paths.
To ensure paths are prefixed properly in the final report, specify an environment variable JACOCO_SOURCE_PATH with a whitespace-separated list of directories containing Java source code (relative to the repository root). Qlty will resolve source code paths and include the full proper path in its coverage report.
Common Scenarios
Docker Containers
Most Docker setups require stripping the container’s working directory:
Monorepos
In monorepos, you may need to add package-specific prefixes:
CI Runners
Different CI providers may generate different path structures:
Verifying Path Fixes
Test with —dry-run
Use dry run to see how paths are being processed:
Validate After Upload
After uploading, check the coverage report in Qlty’s web interface to ensure file paths match your repository structure.
Language-Specific Examples
JavaScript/Node.js
Python
Java
Multi-Module Projects with Jacoco
Jacoco projects may need to specify the environment variable JACOCO_SOURCE_PATH when publishing coverage. See Using JACOCO_SOURCE_PATH.
Go
Ruby
Advanced Path Transformations
Multiple Strip Operations
For complex path structures, you may need multiple transformations:
Troubleshooting
No Files Matched
If Qlty reports no files were matched:
- Check that your repository contains the files referenced in the coverage report
- Verify the path transformations result in valid repository paths
- Use debug mode to see the transformed paths
Missing Coverage Data
If some files are missing from the coverage report:
- Confirm all source files are included in the original coverage report
- Check that path transformations don’t accidentally exclude files
- Verify the coverage tool configuration includes all relevant files
See Also
- Running Tests in Docker - Docker-specific path fixing examples
- CI Integration - CI provider-specific path issues
- Coverage Formats - How different formats handle file paths
- Troubleshooting - General coverage upload issues