Skip to content
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

Generic/ForLoopShouldBeWhileLoop: should for loops without any expression trigger this sniff? #230

Open
1 task done
rodrigoprimo opened this issue Jan 4, 2024 · 0 comments

Comments

@rodrigoprimo
Copy link
Contributor

The Generic.CodeAnalysis.ForLoopShouldBeWhileLoop sniff is used to detect for loops that can be simplified to while loops. Currently, the sniff is triggered only when it finds a for loop that only has the second expression (for (;$test;) {).

While working on #226, I noticed that for loops without any expression (for (;;)) do not trigger this sniff. It is not clear whether this was an intentional decision when the sniff was created or if it was missed.

Per @jrfnl suggestion, I'm opening this issue to gather opinions on whether or not the ForLoopShouldBeWhileLoop sniff should be changed to throw a warning when it finds for loops without any expression. I'm inclined to think that we should change it, but I don't have a strong opinion on this.

  • I intend to create a pull request to implement this feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant