Repository navigation
Exempt baselined files from per-file checks under oneshot_line - #1339
Merged
sferik merged 2 commits intoNov 8, 2026
Merged
Conversation
A baseline records line floors under :line, since oneshot_line results are folded into the :line statistics. minimum_by_file and maximum_missed_by_file asked the baseline about the criterion as configured, :oneshot_line, found no floor, and held a baselined file to the per-file minimum and missed cap it should be exempt from. Look the floor up under SimpleCov.coverage_statistics_key(criterion), which the statistics lookups already use since simplecov-ruby#1170.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change includes targeted regression coverage for both affected exemption paths.
No open issues 🎉
What changed in this PR
This pull request fixes baseline exemptions for per-file coverage thresholds when using oneshot_line. Because oneshot statistics are stored under the line criterion, per-file baseline checks now use the normalized statistics key.
Changes:
- Normalize
oneshot_linetolinefor per-file minimum and missed-cap checks. - Add regression tests for both exemption paths.
- Document the fix in the changelog.
| File | Summary |
|---|---|
spec/simple_cov/coverage_violations_spec.rb |
Adds regression coverage for oneshot per-file minimum and missed-cap exemptions. |
lib/simplecov/coverage_violations.rb |
Uses the normalized statistics key for baseline lookups in per-file checks. |
CHANGELOG.md |
Documents the corrected oneshot baseline behavior. |
Review effort: Lite
sferik
approved these changes
Nov 8, 2026
sferik
left a comment
Collaborator
There was a problem hiding this comment.
Looks good! Thanks for fixing this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
oneshot: true, a file that has an entry in.simplecov_baseline.ymlis still held to the per-file minimum and the per-file missed cap. The baseline is meant to exempt it ("Files with an entry are exempt from the per-file minimum (per criterion)", docs/Configuration.md), and withoutoneshot: trueit is.Reproduction
coverage :linecoverage :line, oneshot: trueWith the baseline, the oneshot run still prints:
Cause
Oneshot results are folded into the
:linestatistics, and a baseline stores line floors under:line.CoverageViolations.minimum_by_fileand.maximum_missed_by_filecalledbaseline.covers?with the configured criterion,:oneshot_line, so no floor was found. Both now map the criterion withSimpleCov.coverage_statistics_key, as the statistics lookups do since #1170.This affects 1.2.0 through 1.3.2.
Testing
spec/simple_cov/coverage_violations_spec.rb, one for the minimum and one for the missed cap. Both fail without the change.bundle exec rspec(6396 examples, 0 failures),standardrbandrubocopwith no offenses, andmutant run 'SimpleCov::CoverageViolations*'(1304 of 1304 mutations killed).