-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks #38738
Merged
akien-mga
merged 4 commits into
godotengine:master
from
akien-mga:cause-we-never-go-out-of-style
May 14, 2020
Merged
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks #38738
akien-mga
merged 4 commits into
godotengine:master
from
akien-mga:cause-we-never-go-out-of-style
May 14, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of godotengine#33027.
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of godotengine#33027.
akien-mga
requested review from
AndreaCatania,
BastiaanOlij,
bojidar-bg,
hpvb,
JFonS,
neikeq,
reduz,
vnen and
a team
as code owners
May 14, 2020 14:56
Duh! Here be bugs, I spent over 2 hours fixing breakage introduced by https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html in that last commit... there might be more that I didn't catch while compiling and reviewing the diff. |
akien-mga
force-pushed
the
cause-we-never-go-out-of-style
branch
from
May 14, 2020 14:58
68187e5
to
77fb6b8
Compare
akien-mga
removed request for
a team,
BastiaanOlij,
hpvb,
JFonS,
bojidar-bg,
vnen,
neikeq and
AndreaCatania
May 14, 2020 14:58
Nice poem :D |
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
akien-mga
force-pushed
the
cause-we-never-go-out-of-style
branch
from
May 14, 2020 19:58
77fb6b8
to
0ee0fa4
Compare
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You got that Allman spacey look in your files
And I got that screen tight, braceless
if
that you likeYet when we go crashing down, we run hooks every time
'Cause we never go out of style, we never go out of style
You've got those long pedantic
clang-tidy
checksAnd I got that
perl
-fu to fix what tools don't getAnd when we go crashing down, we run hooks every time
'Cause we never go out of style, with the One True Brace Style
Part of #33027.