fix: track conditional reassignments in errgroup/spawner checkers#23
Merged
fix: track conditional reassignments in errgroup/spawner checkers#23
Conversation
Same issue as goroutine checker: FuncLitOfIdent only returned the last assignment, missing conditional reassignment patterns. Now errgroup, waitgroup, conc, and spawner checkers properly track all assignments and verify ALL reachable paths capture context. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23 +/- ##
==========================================
+ Coverage 83.96% 84.18% +0.22%
==========================================
Files 24 24
Lines 1808 1834 +26
==========================================
+ Hits 1518 1544 +26
Misses 173 173
Partials 117 117
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Resolved conflict in internal/probe/assignment.go: - Kept FuncLitsAssignedTo from main - Removed duplicate FuncLitAssignmentsOfIdent (already added in main via PR #24)
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
FuncLitAssignmenttype andFuncLitAssignmentsOfIdentmethod to probe packageSpawnCallbackCheckerandSpawnerCheckernow properly track all assignmentsProblem
Same issue as the goroutine checker: when a variable is conditionally reassigned:
The analyzer only checked the last assignment and would incorrectly pass if the conditional branch used context while the unconditional assignment didn't.
Solution
FuncLitAssignmentstruct withConditionalflaginspector.WithStackto detect if assignment is inside control structureTest plan
badConditionalReassignFirstUsesCtx: First uses ctx, conditional doesn't → should warnbadConditionalReassignFirstNoCtx: First doesn't use ctx, conditional does → should warngoodConditionalReassignAllUseCtx: All assignments use ctx → should NOT warn🤖 Generated with Claude Code