From 2d0ece6a03976d19df5a30765429f5f2bf3e00c2 Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 14 Mar 2022 18:01:54 +0100 Subject: [PATCH] clang-format: update. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I tested it against various merge requests and the more I go, the more I wonder if it will ever be *really* useful. It detects so many false positive of totally acceptable code. I tweak the style rules, improve some things but then make other things worse. Actually the logic of having one "best" case with the penalty system is flawed IMO. We should really have rules of what is acceptable and should not trigger changes vs. what is not acceptable styling. For instance what such a system cannot detect is when we organize some things on purpose, for instance for semantic reasons. If it's just "best rule" based, it cannot work, but with an "acceptable style" logic, the on-purpose organization of code will just pass as long as it doesn't break the coding style. Anyway let's see… --- .clang-format | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index 3cf5fde832..786d1bfdc2 100644 --- a/.clang-format +++ b/.clang-format @@ -5,6 +5,8 @@ # --- +BasedOnStyle: GNU + AlignAfterOpenBracket: Align AlignArrayOfStructures: Left AlignConsecutiveAssignments: Consecutive @@ -12,13 +14,18 @@ AlignConsecutiveDeclarations: Consecutive AlignConsecutiveMacros: Consecutive AlignEscapedNewlines: Left +AllowAllParametersOfDeclarationOnNextLine: false AlwaysBreakAfterReturnType: AllDefinitions +BinPackParameters: false BreakBeforeBraces: GNU IndentWidth: 2 -SpaceBeforeParens: Always PointerAlignment: Right UseTab: Never +SpaceBeforeParens: Always +SpaceAfterLogicalNot: true +SpaceAfterCStyleCast: true + # Our column limit is more around 80 characters but we want to avoid # this rule to be over-agressive. So for clang-format, let's use a # higher limit. Then let's put some biggish penalties on breaking on @@ -26,9 +33,10 @@ UseTab: Never # limits, if clang-format really ends up re-formatting, there might be # something better to do code-wise (i.e. we might be in an akwardly # over-nested block case). -ColumnLimit: 100 -PenaltyBreakAssignment: 40 -PenaltyBreakBeforeFirstCallParameter: 40 +ColumnLimit: 80 +PenaltyBreakAssignment: 60 +PenaltyBreakBeforeFirstCallParameter: 100 +PenaltyBreakString: 60 # Uncomment this when we start using clang-format 14 in the CI. # PenaltyBreakOpenParenthesis: 40 PenaltyExcessCharacter: 1