Repository navigation
Fix branch tuple identity mismatches - #1207
Merged
sferik merged 5 commits intoJun 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes branch-coverage tuple identity mismatches that could cause equivalent branches to be duplicated (inflating totals) when combining static branch extraction, runtime branch coverage, and serialized resultsets.
Changes:
- Update static Prism extraction to emit
:unlessforPrism::UnlessNodeand emit safe-navigation branches as:"&.", aligning tuple types with RubyCoverage. - Update branch result merging to merge by
(type, source range)(ignoring the local sequential id) and to normalize serialized tuple keys viaSourceFile::RubyDataParserbefore comparison. - Add focused regression specs plus a changelog entry describing the bugfix.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spec/static_coverage_extractor_spec.rb | Updates/extends specs to assert tuple types for unless and safe navigation match Coverage expectations. |
| spec/combine/branches_combiner_spec.rb | Adds regression tests ensuring equivalent branches merge correctly even when ids differ or keys are serialized strings. |
| lib/simplecov/static_coverage_extractor/visitor.rb | Emits :unless tuples for UnlessNode and adds safe-navigation branch emission for Prism call nodes. |
| lib/simplecov/combine/branches_combiner.rb | Changes merge strategy to use tuple identity based on type + source range, normalizing serialized tuple strings via RubyDataParser. |
| CHANGELOG.md | Documents the bugfix in the unreleased main section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sferik
approved these changes
Jun 21, 2026
sferik
added a commit
that referenced
this pull request
Jun 21, 2026
The visitor now emits :unless for unless nodes (#1207), so the comment's claim that it "reports :if for unless and ternary" was no longer true. Reword to explain the conservative start_line-only matching without citing a specific, now-inaccurate type mismatch.
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.
Summary
Fix branch tuple identity mismatches that can duplicate equivalent branches when static branch extraction, runtime branch coverage, and serialized resultsets are combined.
This PR:
:unlessstatic branch tuples forPrism::UnlessNode, matching Ruby Coverage:\"&.\"branch tuples for safe-navigation calls, matching Ruby CoverageCloses #1206.
Validation
bundle exec rubocoppasses.bundle exec rspec spec/static_coverage_extractor_spec.rb spec/combine/branches_combiner_spec.rbreports29 examples, 0 failures, 2 pending; the command exits2because SimpleCov's own dogfood coverage gate requires 100% whole-project coverage on partial spec runs.bundle exec rakepassed RuboCop and the full RSpec suite with1124 examples, 0 failures, 2 pendingand 100% dogfood line/branch/method coverage, then local Cucumber entered a long retry/failure loop before completion in my environment.Environment
1.0.0.rc3ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x86_64-linux]