-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Consider - forcing braces on loops and if statements. #930
Comments
CSharpier is an opinionated formatter and adding an option goes against that. I would consider always forcing braces, but I don't know how split developers are in the always braces vs no braces. There are also other tools to force braces, they just don't run on save. |
I feel like this is unlikely to get strong consensus in community. Personally, I like no-brace style for short single-line statements like I think it's probably simpler for CSharpier to stick to its "no-syntax change, whitespace formatting-only" general policy on this one. (BTW in the same category: dropping brackets around single-argument, type-less lambdas? Prettier has an option to change |
Yeah, I understand csharpier is opinionated and that adding more options will make the code harder to maintain, so that was just an idea. |
For what it's worth, I have strong opinions on the subject and think that the opinionated nature of CSharpier could implement a set of rules that work well. Always forcing curly braces is the wrong opinion. Especially in C# and our obnoxious Allman standard of braces. However, if within the definition of "opinion" CSharpier will concede to one small stipulation under the following conditions, then I think everyone can be happy: ('block header' is used as a blanket definition for
Number 3 sets forth a limited set of rules for a reasonable standard of when no braces should be allowed. Guard statements are very common and it's really an indicator that the language should provide us with a better construct than I believe these rules in number 3 satisfy the oft quoted argument of "what if you have to add a line of code inside the |
Hello,
It would be nice if we could enforce the curly brackets for conditions and loops. Probably, a strategy for that would be better, something like:
What do you think?
The text was updated successfully, but these errors were encountered: