1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00
revive/testdata/modifies-value-receiver.go
Bryan Boreham 7da6a39044
modifies-value-receiver: warn on slice or map (#943)
* modifies-value-receiver: warn on slice or map

Assignments which index into the slice or map are already ignored on
line 72, and those where the whole receiver is slice or map on line 50.
We should not ignore assignments where the member variable is slice
or map.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>

* Remove extra space

---------

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Co-authored-by: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com>
2023-11-28 15:45:52 +01:00

15 lines
347 B
Go

package fixtures
type data struct {
num int
key *string
items map[string]bool
}
func (this data) vmethod() {
this.num = 8 // MATCH /suspicious assignment to a by-value method receiver/
*this.key = "v.key"
this.items = make(map[string]bool) // MATCH /suspicious assignment to a by-value method receiver/
this.items["vmethod"] = true
}