Open
Description
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.