Skip to content

Fix mapdeletecheck detection with asymmetric parentheses - #71618

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-mapdeletecheck-symmetric-paren
Oct 24, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/fix-mapdeletecheck-symmetric-paren

Conversation

Copilot AI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

mapdeletecheck misses redundant membership checks when map or key expressions have different parenthesis wrapping between the lookup and delete call.

  • Expression matching: Unwrap each operand independently before comparison; remove the symmetric-only ParenExpr case.
  • Regression coverage: Add five diagnostic/autofix cases covering both key directions, map operands, and unequal nesting depths. Autofixes continue using the original lookup expressions.
// Previously missed:
if _, ok := m[(k)]; ok {
	delete(m, k)
}

// Suggested replacement:
delete(m, (k))

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix symmetric ParenExpr wrapping in mapdeletecheck Fix mapdeletecheck detection with asymmetric parentheses Oct 24, 2026
Copilot AI requested a review from pelikhan October 24, 2026 11:05
@pelikhan
pelikhan marked this pull request as ready for review October 24, 2026 11:11
Copilot AI max review requested due to automatic review settings October 24, 2026 11:11
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · sonnet50 · ~17 AIC · ⌖ ~16 AIC · ◇ ~5 AIC · ⊞ 12.7K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · gpt56 · ~6 AIC · ⌖ ~6 AIC · ⊞ 14.8K · ◷

Generated by Ponytail Reviewer for #71618

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

Generated from Design Decision Gate 🏗️ · opus55 · ~11 AIC · ⌖ ~33 AIC · ◇ ~14 AIC · ⊞ 1.9K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@pelikhan
pelikhan merged commit 86f50bf into main Oct 24, 2026
100 of 115 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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))
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.93.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mapdeletecheck: sameExpr requires symmetric ParenExpr wrapping, asymmetric-paren map/key matches escape detection

3 participants