-
Notifications
You must be signed in to change notification settings - Fork 107
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
Rule to detect changes to iterable object of loop #445
Comments
Yeah, I think we've all been here. This sounds good, but I think in general we should just detect if it is a mutable iterable when we see remove in a loop and suggest saving the indexs and then removing them in reverse? Or am I missing something here? Anyways, in general this sounds good. Feel free to make a POC diff and we can comment on there. |
I've went with an approach that alerts for any mutations of the loop iterator (eg PR is in #446 |
FYI: While starting to implement this rule into @cooperlees please hold off the release until I verify my suspicion and fix it ~ I'll check this out later today. |
Ok, I was seeing something, but that code wasn't used - I've opened #488 to remove it, to avoid future bugs 🙂 |
This is released and we have dedicated improvements issue. So let's move there. I yanked 24.1.15 + 24.1.15 due to bugs. |
Recently I've ran into a classic bug in a code base, to illustrate a minimal example:
To nobodies surprise this prints only 1 and 2.
I was surprised that none of my linters caught this.
Anyway, would it be possible to add a rule that detects changes to the iterable that is being iterated?
I'm also more than happy to contribute 🙂
The text was updated successfully, but these errors were encountered: