-
Notifications
You must be signed in to change notification settings - Fork 3k
chore: omit unnecessary reassignment #6622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRemoved redundant per-iteration variable shadowing in three files; two removals are pure cleanup, one (in a concurrency test) removes a loop-variable copy that may alter concurrent capture semantics. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for the PR, @ledigang! Out of curiosity, how did you catch them? $ golangci-lint run -E ineffassign ./...
0 issues. |
Thank you for your review. I am currently using a tool I wrote myself, which is based on golangci-lint, go tools, and a wrapper for go-critic. It is not open source yet (because there are still many false positives and bugs). |
|
I see. The Could you update the remaining occurrences (specifically $ rg -n --no-ignore -g '!**/vendor/**' --pcre2 '\b([A-Za-z_]\w*)\s*:=\s*\1\b(?!\s*[.(])' -C 2
pkg/core/execute_options.go
110-
111- for _, template := range templatesList {
112: template := template
113-
114- select {
pkg/input/formats/burp/burp.go
44- // Print the parsed data for verification
45- for _, item := range items.Items {
46: item := item
47- binx, err := base64.StdEncoding.DecodeString(item.Request.Raw)
48- if err != nil {
pkg/protocols/common/hosterrorscache/hosterrorscache_test.go
178- for i := 1; i <= 100; i++ {
179- wg.Add(1)
180: i := i
181- go func() {
182- defer wg.Done() |
Signed-off-by: ledigang <[email protected]>
Indeed! This regular expression is written brilliantly.
@dogancanbakir @dwisiswant0 Please review it again. |

Proposed changes
The new version of Go has been optimized, and variables do not need to be reassigned.
For more info: https://tip.golang.org/wiki/LoopvarExperiment#does-this-mean-i-dont-have-to-write-x--x-in-my-loops-anymore
Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.