-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Auto-format code #291
Auto-format code #291
Conversation
Currently, I don't have a strong opinion on the exact formatter-setting details to use. But I guess it should be something simple, so for this MR I used the default in VSCode ( @offa @pthom @tom91136 Do you see anything fundamentally wrong with this or with auto-formatting in general for this project? |
Hello Tobias, On my side, I do not see anything wrong with using auto-formatting. It does break the history of files (i.e. git blame will likely stop at such a commit), but in the case of fplus I think this is a minor issue. If you are interested in this, you might want to use editorconfig. It requires a plugin with Visual Studio Code. I cannot say I have a lot of experience with it, but it would be a way to communicate the formatting choices, and let some editors take it into account. I do think that 80 columns is a bit to low for a default (100 looks more sensible to me). Beware, it seems that the auto-formatting went a bit too far, replacing view::ints(0)
| view::take(15000000)
| view::transform(times_3)
| view::remove_if(is_odd_int)
| view::transform(as_string_length)
, 0); by
(which is 135 wide) Merry christmas! |
I usually use https://clang.llvm.org/docs/ClangFormat.html which is supported by VSCode and CLion, and possibly most other IDEs. That way we can keep it all the same (as opposed to being tied to the default of the specific version of the IDE plugin) by writing a ---
AllowShortIfStatementsOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AlignEscapedNewlines: Left
IndentCaseLabels: true
ColumnLimit: 140
CompactNamespaces: true
FixNamespaceComments: true
IndentPPDirectives: BeforeHash
... I generated mine using https://clang-format-configurator.site/ And Merry Christmas! Sorry about opening the two PRs basically on Xmas/boxing day and thanks for reviewing those. |
@pthom Oh, thanks for the remark. I did not notice this ugly format change. And, yes, |
@tom91136 ClangFormat looks good. 👍 I'll play a bit with it and update this PR. And don't worry about PRs on xmas. If I would not want to respond on such days, I feel it's on me to manage my emails/notifications/todos/whatever according to my availability, same as receiving text messages during the night (of the recipient's timezone). 😉 And I enjoyed reviewing/discussing the PRs. 🤓 |
For simplicity, I tried the predefined styles of |
It might be a good idea to verify formatting as part of the CI build once merged. I can work on this if helping hands are needed. 👍 |
@offa That sounds cool! In case it's not too complex, and you already have an idea of how to implement it, I'd be happy if you could help. ❤️ Later, I'd then maybe use whatever you implement here for frugally-deep too. 🙂 |
So far, no auto-formatting was applied (at least by me), which resulted in a somewhat inconsistent code format.