-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
One bug pattern that I've encountered several times is
something like a.x = b.x, or even a.x = a.y = {}
The times I've done it are often when doing change detection, you do x.old = x.new, then mutate x.old, when you meant to do x.old = deepcopy(x.new)
Then, something mutates one of the two variables, and they both change, because they're the same object, and it can be very hard to track down why keys are suddenly appearing for seemingly no reason in your data structures.
Maybe there could be a rule that prevents assigning one mutable property of an object directly or indirectly(like by passing it as a an argument) to another.
It could also warn on assigning one mutable item to multiple objects, or assigning between globals and objects.
Metadata
Metadata
Assignees
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerruleImplementing or modifying a lint ruleImplementing or modifying a lint rule