1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00
Files
revive/testdata/go1.22/redundant_assignment.go
2025-09-24 14:23:20 +02:00

42 lines
902 B
Go

package fixtures
func redundantAssignment() {
for a, b := range collection {
a := a // MATCH /redundant assignment of range variable "a", use it directly/
something(a, b)
}
for a, b := range collection {
for a, b := range collection {
a := a // MATCH /redundant assignment of range variable "a", use it directly/
something(a, b)
}
}
for a, b := range collection {
b := b // MATCH /redundant assignment of range variable "b", use it directly/
something(a, b)
}
for a := range collection {
a := a // MATCH /redundant assignment of range variable "a", use it directly/
something(a, b)
}
for _, a := range collection {
a := a // MATCH /redundant assignment of range variable "a", use it directly/
something(a, b)
}
// should not report
for range collection {
a := a + b
something(a, b)
}
for a, b := range collection {
a := a + b
something(a, b)
}
}