fix(coverage): traverse direct effect payloads - #7137
Conversation
📝 WalkthroughWalkthroughCoverage traversal now discovers executable abilities embedded directly in vote, pile, reveal, delayed-trigger, die, coin-flip, and ChangesDirect effect payload coverage
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/engine/src/game/coverage.rs`:
- Around line 6256-6339: Replace the wildcard arm in
visit_direct_effect_ability_payloads with an exhaustive match arm listing every
current Effect variant that has no direct AbilityDefinition payload, grouping
them with |. Keep the existing payload-visiting arms unchanged, so adding a new
Effect variant forces explicit classification at compile time.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 52e525ee-4def-4970-bdb9-e40a5f4c08e3
📒 Files selected for processing (1)
crates/engine/src/game/coverage.rs
d3971d9 to
50f6918
Compare
|
Generated for head Parse changes introduced by this PR · 1153 card(s), 471 signature(s) (baseline: main
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/engine/src/game/coverage.rs (1)
6768-6774: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider short-circuiting the payload scans.
visit_direct_effect_ability_payloadsruns the closure for every payload. The accumulator patternshas_unimplemented_parts |= ...,supported &= ..., andfound |= ...therefore recurse into every remaining payload subtree after the answer is already known. The result is correct. Only the work is wasted.A shared early-exit helper would remove the duplication across the three sites and stop the traversal at the first match.
♻️ Proposed helper
/// Returns true as soon as a direct payload ability satisfies `pred`. fn any_direct_effect_ability_payload( effect: &Effect, mut pred: impl FnMut(&AbilityDefinition) -> bool, ) -> bool { let mut found = false; visit_direct_effect_ability_payloads(effect, |_, payload| { found = found || pred(payload); }); found }- || { - let mut has_unimplemented_parts = false; - visit_direct_effect_ability_payloads(&def.effect, |_, payload| { - has_unimplemented_parts |= ability_definition_has_unimplemented_parts(payload); - }); - has_unimplemented_parts - } + || any_direct_effect_ability_payload(&def.effect, ability_definition_has_unimplemented_parts)- let mut supported = true; - visit_direct_effect_ability_payloads(&def.effect, |_, payload| { - supported &= is_ability_supported(payload); - }); - if !supported { - return false; - } - true + !any_direct_effect_ability_payload(&def.effect, |payload| !is_ability_supported(payload))Also applies to: 7435-7441, 8261-8267
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/engine/src/game/coverage.rs` around lines 6768 - 6774, Add a shared any_direct_effect_ability_payload helper that evaluates payloads with short-circuiting and returns immediately once the predicate matches. Replace the accumulator closures at the three affected sites around ability_definition_has_unimplemented_parts and the supported/found checks with this helper, preserving each site’s existing predicate and result semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/engine/src/game/coverage.rs`:
- Around line 6768-6774: Add a shared any_direct_effect_ability_payload helper
that evaluates payloads with short-circuiting and returns immediately once the
predicate matches. Replace the accumulator closures at the three affected sites
around ability_definition_has_unimplemented_parts and the supported/found checks
with this helper, preserving each site’s existing predicate and result
semantics.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bac2d1b4-e931-4b29-9ec3-bddfabcd5a6a
📒 Files selected for processing (1)
crates/engine/src/game/coverage.rs
Summary by CodeRabbit