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 <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5e7eee46a3
commit
1993918b9f
@ -118,11 +118,18 @@ PointerAlignment: Right
|
|||||||
# x = (int32)y; not x = (int32) y;
|
# x = (int32)y; not x = (int32) y;
|
||||||
SpaceAfterCStyleCast: false
|
SpaceAfterCStyleCast: false
|
||||||
|
|
||||||
|
# No space is inserted after the logical not operator
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
|
||||||
# Insert spaces before and after assignment operators
|
# Insert spaces before and after assignment operators
|
||||||
# int a = 5; not int a=5;
|
# int a = 5; not int a=5;
|
||||||
# a += 42; a+=42;
|
# a += 42; a+=42;
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
|
||||||
|
# Spaces will be removed before case colon.
|
||||||
|
# case 1: break; not case 1 : break;
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
|
||||||
# Put a space before opening parentheses only after control statement keywords.
|
# Put a space before opening parentheses only after control statement keywords.
|
||||||
# void f() {
|
# void f() {
|
||||||
# if (true) {
|
# if (true) {
|
||||||
@ -134,6 +141,14 @@ SpaceBeforeParens: ControlStatements
|
|||||||
# Don't insert spaces inside empty '()'
|
# Don't insert spaces inside empty '()'
|
||||||
SpaceInEmptyParentheses: false
|
SpaceInEmptyParentheses: false
|
||||||
|
|
||||||
|
# No space before first '[' in arrays
|
||||||
|
# int a[5][5]; not int a [5][5];
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
|
||||||
|
# No space will be inserted into {}
|
||||||
|
# while (true) {} not while (true) { }
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
|
||||||
# The number of spaces before trailing line comments (// - comments).
|
# The number of spaces before trailing line comments (// - comments).
|
||||||
# This does not affect trailing block comments (/* - comments).
|
# This does not affect trailing block comments (/* - comments).
|
||||||
SpacesBeforeTrailingComments: 1
|
SpacesBeforeTrailingComments: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user