Repository navigation
Fix mapdeletecheck detection with asymmetric parentheses - #71618
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Review summary
No actionable issues found in the changed lines. Independently checked the parenthesis unwrapping against the existing sameExpr cases and the new asymmetric-parenthesis fixtures; the change preserves identifier/type-identity comparisons while extending matching as intended. Static review only; no tests were run.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
🟢 Approval recommended
The localized matching fix preserves autofix behavior, with only non-blocking test-fixture improvements remaining.
1 open issue
What changed in this PR
Fixes mapdeletecheck false negatives when lookup and delete operands have different parenthesis wrapping, while preserving lookup-based autofixes.
Changes:
- Unwrap both comparison operands independently and remove the symmetric-only parenthesis case.
- Add parenthesized map/key diagnostic fixtures and expected autofix output.
| File | Description |
|---|---|
pkg/linters/mapdeletecheck/testdata/src/mapdeletecheck/mapdeletecheck.go.golden |
Expected autofixes for the new fixtures. |
pkg/linters/mapdeletecheck/testdata/src/mapdeletecheck/mapdeletecheck.go |
Diagnostic cases for parenthesized map and key operands. |
pkg/linters/mapdeletecheck/mapdeletecheck.go |
Independent parenthesis unwrapping during expression comparison. |
Review effort: Max
|
|
||
| // want +1 `redundant existence check before delete` | ||
| if _, ok := (m)[(k)]; ok { | ||
| delete((m), (k)) |
|
🎉 This pull request is included in a new release. Release: |

mapdeletecheckmisses redundant membership checks when map or key expressions have different parenthesis wrapping between the lookup anddeletecall.ParenExprcase.