clang-tidy readability-braces-around-statements #3699
Merged
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.
Description
This PR adds
readability-braces-around-statements
to .clang-tidy. It is based on experimental work under PR #3698.A few manual fix-ups are needed in preparation, to work around clang-tidy bugs. The rest of the changes are automatically generated by running clang-tidy.
Alternative considered:
readability-misleading-indentation
That would be more similar to Python and save us a bunch of lines with closing braces, but consider that C++ has a lot more syntactical noise and, unlike Python, comes with a preprocessor. For example:
Without braces constructs like this are almost certain to cause confusion while debugging, or when going through with large-scale changes. The braces seem very useful as visual anchors, protecting against misreading the code.
See also: #3698 (comment)
Suggested changelog entry:
clang-tidy `readability-braces-around-statements` is now enforced pre-commit.