Skip to content

Commit 1993918

Browse files
KarthikNayakgitster
authored andcommitted
clang-format: formalize some of the spacing rules
There are some spacing rules that we follow in the project and it makes sense to formalize them: * Ensure there is no space inserted after the logical not '!' operator. * Ensure there is no space before the case statement's colon. * Ensure there is no space before the first bracket '[' of an array. * Ensure there is no space in empty blocks. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e7eee4 commit 1993918

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.clang-format

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,18 @@ PointerAlignment: Right
118118
# x = (int32)y; not x = (int32) y;
119119
SpaceAfterCStyleCast: false
120120

121+
# No space is inserted after the logical not operator
122+
SpaceAfterLogicalNot: false
123+
121124
# Insert spaces before and after assignment operators
122125
# int a = 5; not int a=5;
123126
# a += 42; a+=42;
124127
SpaceBeforeAssignmentOperators: true
125128

129+
# Spaces will be removed before case colon.
130+
# case 1: break; not case 1 : break;
131+
SpaceBeforeCaseColon: false
132+
126133
# Put a space before opening parentheses only after control statement keywords.
127134
# void f() {
128135
# if (true) {
@@ -134,6 +141,14 @@ SpaceBeforeParens: ControlStatements
134141
# Don't insert spaces inside empty '()'
135142
SpaceInEmptyParentheses: false
136143

144+
# No space before first '[' in arrays
145+
# int a[5][5]; not int a [5][5];
146+
SpaceBeforeSquareBrackets: false
147+
148+
# No space will be inserted into {}
149+
# while (true) {} not while (true) { }
150+
SpaceInEmptyBlock: false
151+
137152
# The number of spaces before trailing line comments (// - comments).
138153
# This does not affect trailing block comments (/* - comments).
139154
SpacesBeforeTrailingComments: 1

0 commit comments

Comments
 (0)