[SERVER-19119] clang-format configuration uses AlignAfterOpenBracket true instead of false Created: 24/Jun/15  Updated: 05/Apr/17  Resolved: 23/May/16

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 3.1.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Matt Dannenberg Assignee: Mark Benvenuto
Resolution: Won't Fix Votes: 2
Labels: clang-format
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platforms 15 (06/03/16)
Participants:

 Description   

This violates our style guide. Here is example output from clang-format asking me to replace my 8 space continuation indent with a 4 space one:

mongo % python buildscripts/clang_format.py lint
Running across 24 cpus
ERROR: Found diff for /home/dannenberg/work/server6071/mongo/src/mongo/db/dbcommands.cpp
To fix formatting errors, run /usr/bin/clang-format --style=file -i /home/dannenberg/work/server6071/mongo/src/mongo/db/dbcommands.cpp
---
+++
@@ -1309,7 +1309,7 @@
 
     const auto& metadata = request.getMetadata();
     if (replCoord->getReplicationMode() == repl::ReplicationCoordinator::Mode::modeReplSet &&
-            metadata.hasField(rpc::kReplicationMetadataFieldName)) {
+        metadata.hasField(rpc::kReplicationMetadataFieldName)) {
         BSONObjBuilder replInfoBob(metadataBob.subobjStart(rpc::kReplicationMetadataFieldName));
         replCoord->prepareReplResponseMetadata(&replInfoBob);
     }
ERROR: Code Style does not match coding style



 Comments   
Comment by Mark Benvenuto [ 23/May/16 ]

During a vote for 3.4 timeframe among Server leads, the proposed formatting change has been rejected. Closing as Won't Fix as a result.

Comment by Mark Benvenuto [ 22/Mar/16 ]

The previous example also relied on ContinuationIndentWidth being changed to 8.

Comment by Mark Benvenuto [ 25/Jun/15 ]

If we change the indentation format for AlignAfterOpenBracket to false, these are the resulting changes:

diff --git a/etc/format_sample.cpp b/etc/format_sample.cpp
index b5b98b5..9724c30 100644
--- a/etc/format_sample.cpp
+++ b/etc/format_sample.cpp
@@ -76,9 +76,8 @@ T myAdd(T x, T y) {
 
 // AlwaysBreakAfterDefinitionReturnType: false
 // BinPackParameters: false
-int Example::manyVariableFunction(unsigned long long argWithLongName,
-                                  char arg2,
-                                  unsigned long long argWithAnotherLongName) {
+int Example::manyVariableFunction(
+        unsigned long long argWithLongName, char arg2, unsigned long long argWithAnotherLongName) {
     // 3.7 - AlignConsecutiveAssignments - false
     //
     int aaaa = 12;
@@ -111,12 +110,12 @@ int Example::manyVariableFunction(unsigned long long argWithLongName,
 
     int bbbbbbbbbbbbbbbbbbbbbbbbbbbb, cccccccccccccccccccccccccccccc;
     int aaaaaaaaaaaaaaaaaaaaaaaaaaaa =
-        bbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccccccccc;
+            bbbbbbbbbbbbbbbbbbbbbbbbbbbb + cccccccccccccccccccccccccccccc;
 
     // AlignOperands
     int dddddddddddddddddddddddddddd = aaaaaaaaaaaaaaaaaaaaaaaaaaaa * 7 + 4 % 235124 > 275645
-        ? bbbbbbbbbbbbbbbbbbbbbbbbbbbb + 897234
-        : cccccccccccccccccccccccccccccc % 1293402;
+            ? bbbbbbbbbbbbbbbbbbbbbbbbbbbb + 897234
+            : cccccccccccccccccccccccccccccc % 1293402;
 
     // AllowShortBlocksOnASingleLine: false
     if (b) {
@@ -129,7 +128,7 @@ int Example::manyVariableFunction(unsigned long long argWithLongName,
 
     // BreakBeforeBinaryOperators: None
     if (b > 5 || b % 42 || cccccccccccccccccccccccccccccc % 873 || aaaa * 12312 % 23485 != 9873 ||
-        some_pointer != 0) {
+            some_pointer != 0) {
         printf("Huh!\n");
     }
 
@@ -137,10 +136,10 @@ int Example::manyVariableFunction(unsigned long long argWithLongName,
     // BinPackParameters: false
     printf("A short function call %s %s %d - %ld\n", "", "tgz", 4, ULONG_MAX);
     printf("A long function call %s %s %d - %ld\n",
-           "http://www.mongodbo.org/downloads",
-           "mongodb-latest.tgz",
-           4,
-           ULONG_MAX);
+            "http://www.mongodbo.org/downloads",
+            "mongodb-latest.tgz",
+            4,
+            ULONG_MAX);
     printf("Thing1 %s\n", "Thing2");
 
     // No spaces between parens and args

Generated at Thu Feb 08 03:49:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.