Skip to content

Commit 9e45fc6

Browse files
KarthikNayakgitster
authored andcommitted
clang-format: set 'ColumnLimit' to 0
When clang-format was introduced to the Git project in 6134de6 (clang-format: outline the git project's coding style, 2017-08-14), the 'ColumnLimit' was set to 80. This is inline with our recommendation in 'Documentation/CodingGuidelines', which states: We try to keep to at most 80 characters per line. However while this is recommended limit, this is not the enforced limit. In some cases in we do overflow this limit to prioritize readability. Setting the 'ColumnLimit' also means that shorter lines are concatenated to simply as the result would still be below 80 characters, which is undesirable. In the past, we tried to adjust the penalties around line wrapping, once in 42efde4 (clang-format: adjust line break penalties, 2017-09-29) and another time in 5e9fa0f (clang-format: re-adjust line break penalties, 2024-10-18). While these settings help tweak the line break penalties to be more in-line with the requirements of the Git project, using 'clang-format' still produces a lot of false positives. So to make 'clang-format' more usable, set the 'ColumnLimit' to 0. This means that line-wrapping is no-longer a concern of the formatter and something that the user needs to take care of. The previous commit also added a more flexible guideline to the '.editorconfig' setting a 'max_line_length' of 120 characters. This should provide some guidance to users. In the future, it would be nice to re-instate this limit with adequate penalties which would follow our guidelines, but currently, it makes more sense to have a working formatter which we can rely on and which doesn't create too many false positives. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit 9e45fc6

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

.clang-format

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ UseTab: Always
1212
TabWidth: 8
1313
IndentWidth: 8
1414
ContinuationIndentWidth: 8
15-
ColumnLimit: 80
15+
16+
# While we do want to enforce a character limit of 80 characters, we often
17+
# allow lines to overflow that limit to prioritize readability. Setting a
18+
# character limit here with penalties has been finicky and creates too many
19+
# false positives.
20+
#
21+
# NEEDSWORK: It would be nice if we can find optimal settings to ensure we
22+
# can re-enable the limit here.
23+
ColumnLimit: 0
1624

1725
# C Language specifics
1826
Language: Cpp
@@ -210,16 +218,5 @@ MaxEmptyLinesToKeep: 1
210218
# No empty line at the start of a block.
211219
KeepEmptyLinesAtTheStartOfBlocks: false
212220

213-
# Penalties
214-
# This decides what order things should be done if a line is too long
215-
PenaltyBreakAssignment: 5
216-
PenaltyBreakBeforeFirstCallParameter: 5
217-
PenaltyBreakComment: 5
218-
PenaltyBreakFirstLessLess: 0
219-
PenaltyBreakOpenParenthesis: 300
220-
PenaltyBreakString: 5
221-
PenaltyExcessCharacter: 10
222-
PenaltyReturnTypeOnItsOwnLine: 300
223-
224221
# Don't sort #include's
225222
SortIncludes: false

0 commit comments

Comments
 (0)