Skip to content

feat: add SuggestedFixes for --fix support#19

Open
raeperd wants to merge 2 commits intomainfrom
feat/suggested-fixes
Open

feat: add SuggestedFixes for --fix support#19
raeperd wants to merge 2 commits intomainfrom
feat/suggested-fixes

Conversation

@raeperd
Copy link
Copy Markdown
Owner

@raeperd raeperd commented Apr 3, 2026

Why

golangci-lint supports --fix to auto-fix linter issues, but recvcheck only reports diagnostics without suggested fixes. Users have to manually change value receivers to pointer receivers.

What

Attach analysis.SuggestedFix with TextEdits that insert * before value receiver type names. When golangci-lint --fix is used, value receivers are automatically converted to pointer receivers.

Changes

  • Switch pass.Reportfpass.Report(analysis.Diagnostic{...}) with SuggestedFixes
  • Track value receiver *ast.Ident positions during AST walk
  • Switch tests to analysistest.RunWithSuggestedFixes with .go.golden files

Summary by CodeRabbit

  • New Features

    • Analyzer now provides automatic suggested fixes to convert non-pointer method receivers to pointer receivers, with text edits applied at the identifier positions.
  • Tests

    • Updated test harness to verify suggested fixes alongside diagnostics.
    • Added comprehensive test fixtures covering various serialization patterns.

raeperd added 2 commits April 4, 2026 00:07
Attach SuggestedFixes to diagnostics so golangci-lint --fix can
automatically convert value receivers to pointer receivers.
Switch tests to RunWithSuggestedFixes and add golden files.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3472fb74-f79e-4bec-a319-49299e954455

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/suggested-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

@raeperd raeperd self-assigned this Apr 3, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@analyzer.go`:
- Around line 105-112: The call pass.Pkg.Scope().Lookup(recv) can return nil and
calling .Pos() would panic; update the diagnostic creation in the block that
calls pass.Report so you first capture the result of
pass.Pkg.Scope().Lookup(recv) into a variable, check for nil, and use a safe
fallback position (for example token.NoPos or the position of the first related
method) when lookup is nil before passing Pos into analysis.Diagnostic; keep the
same Message and SuggestedFixes logic but supply the guarded position to avoid
nil dereference.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 833209dd-ae10-4d4a-9520-d22f79cd0e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 8ade7fa and c0ef36c.

📒 Files selected for processing (9)
  • analyzer.go
  • analyzer_test.go
  • testdata/src/basic/rpc.go.golden
  • testdata/src/disablebuiltin/binary.go.golden
  • testdata/src/disablebuiltin/gob.go.golden
  • testdata/src/disablebuiltin/json.go.golden
  • testdata/src/disablebuiltin/text.go.golden
  • testdata/src/disablebuiltin/xml.go.golden
  • testdata/src/disablebuiltin/yaml.go.golden

Comment thread analyzer.go
@raeperd raeperd marked this pull request as ready for review April 3, 2026 16:14
@raeperd raeperd requested a review from ldez April 3, 2026 16:14
@ldez ldez added the enhancement New feature or request label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants