-
Notifications
You must be signed in to change notification settings - Fork 129
checkers: add rangeAppendAll #1423
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
Signed-off-by: alingse <alingse@foxmail.com>
@cristaloleg would you review it when you have time? |
Hey @alingse I'm not sure this is a good general check. @quasilyte ? |
I search the top github repos, and find this bugs, they are all the same wrong pattern for _, p := range pluginsForDatamover {
if !slices.Contains(plugins, p) {
plugins = append(plugins, pluginsForDatamover...) // Wrong
}
} for _, v := range childNodes {
if v.Type() == NWhen {
n.whenNodes = append(n.whenNodes, childNodes...) // Wrong
} for _, ip := range ips {
if ip.IsCollinear {
continue
}
ii.Intersections = append(ii.Intersections, ips...) // Wrong
} I think it is a rare but general mistake, and I add for i, v := range remaining {
r := append([]int(nil), remaining...) // copy remaining
r = append(r[:i], r[i+1:]...) // delete placed index
p := permute(append(placed, v), r) // place index and permute
permutations = append(permutations, p...)
} 🤔 |
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Signed-off-by: alingse <alingse@foxmail.com>
Signed-off-by: alingse <alingse@foxmail.com>
@alexandear I have update the commits. |
@alexandear this PR need your review again. |
@cristaloleg @quasilyte Could you review this PR and merge it if it is ok? 🤔 |
@quasilyte need your help. would you review this PR ? |
@cristaloleg could you merge it? and make a new release ? |
This is a bug I discovered during work.
append all its data while range over it is generally not the intended behavior and can lead to duplicate data.
I implemented the checker firstly in my repo and use the go-linter-runner github action to scan top 10k Go repos. This found real bugs, documented in alingse/sundrylint#1