Conversation
Attach SuggestedFixes to diagnostics so golangci-lint --fix can automatically convert value receivers to pointer receivers. Switch tests to RunWithSuggestedFixes and add golden files.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (9)
analyzer.goanalyzer_test.gotestdata/src/basic/rpc.go.goldentestdata/src/disablebuiltin/binary.go.goldentestdata/src/disablebuiltin/gob.go.goldentestdata/src/disablebuiltin/json.go.goldentestdata/src/disablebuiltin/text.go.goldentestdata/src/disablebuiltin/xml.go.goldentestdata/src/disablebuiltin/yaml.go.golden
Why
golangci-lint supports
--fixto 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.SuggestedFixwithTextEdits that insert*before value receiver type names. Whengolangci-lint --fixis used, value receivers are automatically converted to pointer receivers.Changes
pass.Reportf→pass.Report(analysis.Diagnostic{...})withSuggestedFixes*ast.Identpositions during AST walkanalysistest.RunWithSuggestedFixeswith.go.goldenfilesSummary by CodeRabbit
New Features
Tests