Skip to content

Issue with PR formatting in Fedora 42 (newer clang-format) #2263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jrohel opened this issue May 27, 2025 · 2 comments
Open

Issue with PR formatting in Fedora 42 (newer clang-format) #2263

jrohel opened this issue May 27, 2025 · 2 comments
Labels
Priority: MEDIUM Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take

Comments

@jrohel
Copy link
Contributor

jrohel commented May 27, 2025

Clang-format 20.1.3 in Fedora 42 formats code differently than clang-format 19.1.7 in Fedora 41 and earlier, causing issues with the pre-commit format check.

clang-format version 19.1.7 (Fedora 19.1.7-3.fc41)

    testv(std::vector<std::string>{
        "the first long test string argument is here", "the second long test string argument is here"});

clang-format version 20.1.3 (Fedora 20.1.3-1.fc42)

    testv(
        std::vector<std::string>{
            "the first long test string argument is here", "the second long test string argument is here"});

Examples of reformatting existing code:

-        std::string("Meson is an open source build system meant to be both extremely fast, and, even more importantly, "
-                    "as user friendly as possible.\nThe main design point of Meson is that every moment a developer "
-                    "spends writing or debugging build definitions is a second wasted. So is every second spent "
-                    "waiting for the build system to actually start compiling code."),
+        std::string(
+            "Meson is an open source build system meant to be both extremely fast, and, even more importantly, "
+            "as user friendly as possible.\nThe main design point of Meson is that every moment a developer "
+            "spends writing or debugging build definitions is a second wasted. So is every second spent "
+            "waiting for the build system to actually start compiling code."),
-    base->get_config().get_varsdir_option().set(std::vector<std::string>{
-        PROJECT_SOURCE_DIR "/test/libdnf5/conf/data/vars",
-        PROJECT_SOURCE_DIR "/test/libdnf5/conf/data/vars2",
-    });
+    base->get_config().get_varsdir_option().set(
+        std::vector<std::string>{
+            PROJECT_SOURCE_DIR "/test/libdnf5/conf/data/vars",
+            PROJECT_SOURCE_DIR "/test/libdnf5/conf/data/vars2",
+        });
-        CPPUNIT_FAIL(fmt::format(
-            "No package \"{}\" found. All sack packages:{}", what, to_string(libdnf5::rpm::PackageQuery(base))));
+        CPPUNIT_FAIL(
+            fmt::format(
+                "No package \"{}\" found. All sack packages:{}", what, to_string(libdnf5::rpm::PackageQuery(base))));
@jrohel
Copy link
Contributor Author

jrohel commented May 27, 2025

It looks like clang-format has changed its behavior for AlignAfterOpenBracket: AlwaysBreak. It's necessary to determine whether this can be fixed by modifying the .clang-format configuration file or if it's a breaking change in clang-format.

@ppisar ppisar added Priority: MEDIUM Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take labels May 27, 2025
@ppisar
Copy link
Contributor

ppisar commented May 27, 2025

clang release notes: https://releases.llvm.org/20.1.0/tools/clang/docs/ReleaseNotes.html#clang-format

A difference in clang-format -style=Google -dump-config output between 19.1.7 and 20.1.3:

--- format-19.1.7	2025-05-27 10:29:55.355295944 +0200
+++ format-20.1.3	2025-05-27 10:30:25.946810994 +0200
@@ -8,6 +8,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    true
 AlignConsecutiveBitFields:
@@ -15,6 +16,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    false
 AlignConsecutiveDeclarations:
@@ -22,6 +24,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: true
   AlignFunctionPointers: false
   PadOperators:    false
 AlignConsecutiveMacros:
@@ -29,6 +32,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    false
 AlignConsecutiveShortCaseStatements:
@@ -42,6 +46,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    false
 AlignConsecutiveTableGenCondOperatorColons:
@@ -49,6 +54,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    false
 AlignConsecutiveTableGenDefinitionColons:
@@ -56,6 +62,7 @@
   AcrossEmptyLines: false
   AcrossComments:  false
   AlignCompound:   false
+  AlignFunctionDeclarations: false
   AlignFunctionPointers: false
   PadOperators:    false
 AlignEscapedNewlines: Left
@@ -75,12 +82,13 @@
 AllowShortIfStatementsOnASingleLine: WithoutElse
 AllowShortLambdasOnASingleLine: All
 AllowShortLoopsOnASingleLine: true
+AllowShortNamespacesOnASingleLine: false
 AlwaysBreakAfterDefinitionReturnType: None
 AlwaysBreakBeforeMultilineStrings: true
 AttributeMacros:
   - __capability
 BinPackArguments: true
-BinPackParameters: true
+BinPackParameters: BinPack
 BitFieldColonSpacing: Both
 BraceWrapping:
   AfterCaseLabel:  false
@@ -111,6 +119,7 @@
 BreakBeforeBraces: Attach
 BreakBeforeInlineASMColon: OnlyMultiline
 BreakBeforeTernaryOperators: true
+BreakBinaryOperations: Never
 BreakConstructorInitializers: BeforeColon
 BreakFunctionDefinitionParameters: false
 BreakInheritanceList: BeforeColon
@@ -157,6 +166,7 @@
 IndentAccessModifiers: false
 IndentCaseBlocks: false
 IndentCaseLabels: true
+IndentExportBlock: true
 IndentExternBlock: AfterExternBlock
 IndentGotoLabels: true
 IndentPPDirectives: None
@@ -179,6 +189,7 @@
   AtEndOfFile:     false
   AtStartOfBlock:  false
   AtStartOfFile:   true
+KeepFormFeed:    false
 LambdaBodyIndentation: Signature
 LineEnding:      DeriveLF
 MacroBlockBegin: ''
@@ -194,6 +205,7 @@
 PackConstructorInitializers: NextLine
 PenaltyBreakAssignment: 2
 PenaltyBreakBeforeFirstCallParameter: 1
+PenaltyBreakBeforeMemberAccess: 150
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakOpenParenthesis: 0
@@ -237,8 +249,9 @@
     CanonicalDelimiter: pb
     BasedOnStyle:    google
 ReferenceAlignment: Pointer
-ReflowComments:  true
+ReflowComments:  Always
 RemoveBracesLLVM: false
+RemoveEmptyLinesInUnwrappedLines: false
 RemoveParentheses: Leave
 RemoveSemicolon: false
 RequiresClausePosition: OwnLine
@@ -304,5 +317,6 @@
   - NS_SWIFT_NAME
   - PP_STRINGIZE
   - STRINGIZE
+WrapNamespaceBodyWithEmptyLines: Leave
 ...
 ~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: MEDIUM Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
None yet
Development

No branches or pull requests

2 participants