[SERVER-19249] Clang-format should allow BSON macro to be used with one key-value pair per line Created: 01/Jul/15  Updated: 15/Oct/19  Resolved: 15/Oct/19

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

Type: Task Priority: Major - P3
Reporter: Spencer Brody (Inactive) Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Fix Votes: 0
Labels: clang-format
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-19184 clang-format does odd things with BSO... Closed
Participants:

 Description   

ERROR: Found diff for /media/ssd/mongo4/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp
To fix formatting errors, run /usr/bin/clang-format-3.6 --style=file -i /media/ssd/mongo4/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp
---
+++
@@ -89,9 +89,8 @@
         onCommand([&](const RemoteCommandRequest& request) {
             ASSERT_EQUALS(configHost, request.target);
             ASSERT_EQUALS("config", request.dbname);
-            BSONObj expectedCreateCmd = BSON("create" << ChangelogType::ConfigNS <<
-                                             "capped" << true <<
-                                             "size" << 1024 * 1024 * 10);
+            BSONObj expectedCreateCmd = BSON("create" << ChangelogType::ConfigNS << "capped" << true
+                                                      << "size" << 1024 * 1024 * 10);
             ASSERT_EQUALS(expectedCreateCmd, request.cmdObj);
 
             return BSON("ok" << 1);
ERROR: Code Style does not match coding style



 Comments   
Comment by Githook User [ 23/Feb/17 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-19249 Stringify arguments in ASSERT_BSON* before they are macro-expanded

before:
TestName Expected [ ((::mongo::BSONObjBuilder(64) << "a" << 1).obj()) == ((::mongo::BSONObjBuilder(64) << "a" << 2).obj()) ] but found [

{ a: 1 }

==

{ a: 2 }

] @file:123

after:
TestName Expected [ BSON("a" << 1) == BSON("a" << 2) ] but found [

{ a: 1 }

==

{ a: 2 }

] @file:123
Branch: master
https://github.com/mongodb/mongo/commit/20af425dabe7201c8a48d748b4e9d6bed086372e

Comment by Mark Benvenuto [ 03/May/16 ]

There is no way to hint that the << should be treated as key value pairs in the BSON macro. Formatting for << is a little different in 3.8.0, but it never format as we want without customization.

Since this cannot be done with clang-format 3.8.0, moving it to planned but not scheduled.

Comment by Mathias Stearn [ 30/Jul/15 ]

Ditto for the BSON_ARRAY, DOC and DOC_ARRAY macros

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