git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] clang-format: adjust line break penalties
@ 2017-09-29 18:26 Johannes Schindelin
  2017-09-29 18:40 ` Jonathan Nieder
  0 siblings, 1 reply; 15+ messages in thread
From: Johannes Schindelin @ 2017-09-29 18:26 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Brandon Williams

We really, really, really want to limit the columns to 80 per line: One
of the few consistent style comments on the Git mailing list is that the
lines should not have more than 80 columns/line (even if 79 columns/line
would make more sense, given that the code is frequently viewed as diff,
and diffs adding an extra character).

The penalty of 5 for excess characters is way too low to guarantee that,
though, as pointed out by Brandon Williams.

From the existing clang-format examples and documentation, it appears
that 100 is a penalty deemed appropriate for Stuff You Really Don't
Want, so let's assign that as the penalty for "excess characters", i.e.
overly long lines.

While at it, adjust the penalties further: we are actually not that keen
on preventing new line breaks within comments or string literals, so the
penalty of 100 seems awfully high.

Likewise, we are not all that adamant about keeping line breaks away
from assignment operators (a lot of Git's code breaks immediately after
the `=` character just to keep that 80 columns/line limit).

We do frown a little bit more about functions' return types being on
their own line than the penalty 0 would suggest, so this was adjusted,
too.

Finally, we do not particularly fancy breaking before the first parameter
in a call, but if it keeps the line shorter than 80 columns/line, that's
what we do, so lower the penalty for breaking before a call's first
parameter, but not quite as much as introducing new line breaks to
comments.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/git/releases/tag/clang-format-column-limit-v1
Fetch-It-Via: git fetch https://github.com/dscho/git clang-format-column-limit-v1
 .clang-format | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/.clang-format b/.clang-format
index 3ede2628d2d..56822c116b1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -153,13 +153,13 @@ KeepEmptyLinesAtTheStartOfBlocks: false
 
 # Penalties
 # This decides what order things should be done if a line is too long
-PenaltyBreakAssignment: 100
-PenaltyBreakBeforeFirstCallParameter: 100
-PenaltyBreakComment: 100
+PenaltyBreakAssignment: 10
+PenaltyBreakBeforeFirstCallParameter: 30
+PenaltyBreakComment: 10
 PenaltyBreakFirstLessLess: 0
-PenaltyBreakString: 100
-PenaltyExcessCharacter: 5
-PenaltyReturnTypeOnItsOwnLine: 0
+PenaltyBreakString: 10
+PenaltyExcessCharacter: 100
+PenaltyReturnTypeOnItsOwnLine: 5
 
 # Don't sort #include's
 SortIncludes: false

base-commit: ea220ee40cbb03a63ebad2be902057bf742492fd
-- 
2.14.2.windows.1

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-10-03  1:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 18:26 [PATCH] clang-format: adjust line break penalties Johannes Schindelin
2017-09-29 18:40 ` Jonathan Nieder
2017-09-29 19:50   ` Brandon Williams
2017-09-29 22:39   ` Stephan Beyer
2017-09-29 22:45     ` Jonathan Nieder
2017-09-30 21:37       ` [PATCH] Add a comment to .clang-format about the meaning of the file Stephan Beyer
2017-10-01  2:45         ` Junio C Hamano
2017-10-01 15:44       ` [PATCH v2] " Stephan Beyer
2017-10-01 20:30         ` Junio C Hamano
2017-10-01 21:29           ` Stephan Beyer
2017-10-01 23:37         ` [PATCH v3] clang-format: add a comment about the meaning/status of the Junio C Hamano
2017-10-02 17:16           ` Stephan Beyer
2017-10-02 17:21           ` Brandon Williams
2017-10-03  1:08             ` Ramsay Jones
2017-10-01  2:40   ` [PATCH] clang-format: adjust line break penalties Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).