-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
empty_loop_body
must honor comments
#6040
Comments
I see nothing critical here, the comment is not removed. I would reconfigure the rule to add the |
@SpacePossum let's question this rule from the other side - why is it any good that the loop body is placed after the loop? |
I tend to agree comments should be considered part of the loop and prevent the braces from being removed, e.g. to make things explicit: while (foo()) {
// no-op
} |
So configure it with For example, from the other side:
should this be fixed because we assume this comment is a body?
who about this than?
adding all these exceptions and details are just to harmful for the code base IMHO. As such I won't add this, review it and will vote 👎 on it, if there is a majority for the change and a reviewer amongst the members than we can reopen here |
The typical usecase is:
whis is currently converted to:
which completely changes the meaning of the code/comment. I think this rule should apply strictly only when there is nothing inside the loop body, even if only a comment |
@SpacePossum Those are valid reasons :) To be honest, I don't feel like implementing it myself as well, empty loops that contain actual comments (i.e. not commented out code) are very rare, though I'd be ok if one would contribute it. |
If we can all agree that the reasons are valid, I might contribute the fix, should be easy :) |
please reaopen this issue |
why? if you want multi line body for comments config |
Because this rule "basically scriples" meaning of a code. If something is inside loop body, it is meant to be evaluated per iteration, not after the loop/once. |
so configure the rule to use |
I use default config. @julienfalque was also thinks this should be fixed. @SpacePossum, why you defend moving comments outside the body after the loop, is there any ratonale? |
I didn't set the default and I certainly never ever told you to you use, so if you use it than why ask me? I cannot reason why you are you use this configuration |
Thanks. The rule itself and even both configs are ok. The only issue I have is that it should be considered non-empty when there is a comment inside. This is the only change I ask for, therefore, I kindly ask you to reopen this issue so someone can fix that. |
I'm not interested in that exception in the core of this project, so I won't reopen this. The tool accepts 3rd party rules so would advice that, such rule can have configuration and defaults of its own. |
Bug report
empty_loop_body
must honor comments and keep curly brackets around the body. This is critical as commented code (which can be uncommented later) inside loop body has significantly other meaning tham code placed below the loop.Code snippet that reproduces the problem
The text was updated successfully, but these errors were encountered: