[SERVER-19184] clang-format does odd things with BSON doc Created: 29/Jun/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: Bug Priority: Major - P3
Reporter: Martin Bligh 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
related to SERVER-19249 Clang-format should allow BSON macro ... Closed
Operating System: ALL
Sprint: Platform 6 07/17/15
Participants:

 Description   

Insists on reverting this:

diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
index aae1056..9a4a0e0 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_test.cpp
@@ -541,8 +541,7 @@ TEST(WiredTigerRecordStoreTest, OplogHack) {
                 rs->insertRecord(opCtx.get(), obj.objdata(), obj.objsize(), false).getStatus(),
                 ErrorCodes::BadValue);
 
-            obj = BSON("ts"
-                       << "not a Timestamp");
+            obj = BSON("ts" << "not a Timestamp");
             ASSERT_EQ(
                 rs->insertRecord(opCtx.get(), obj.objdata(), obj.objsize(), false).getStatus(),
                 ErrorCodes::BadValue);



 Comments   
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 Eric Milkie [ 20/Nov/15 ]

I have anecdotal evidence that a newer version of clang-format behaves better W.R.T. this.

Comment by Martin Bligh [ 29/Jun/15 ]

Actually is the same error - it was reverting my patch above.

Comment by James Cohan [ 29/Jun/15 ]

It also doesn't allow me to put key value pairs on the same line.

+++
@@ -921,10 +921,14 @@
 /** A complex _id expression. */
 class ComplexId : public CheckResultsBase {
     std::deque<Document> inputData() {
-        return {DOC("a" << "de"
-                 << "b" << "ad"
-                 << "c" << "beef"
-                 << "d" << ""),
+        return {DOC("a"
+                    << "de"
+                    << "b"
+                    << "ad"
+                    << "c"
+                    << "beef"
+                    << "d"
+                    << ""),
                 DOC("a"
                     << "d"
                     << "b"

Comment by James Cohan [ 29/Jun/15 ]

I'm getting the opposite of this error. When I try to put two values on the same line, it insists on moving the second value to a new line.

+++
@@ -1793,7 +1793,8 @@
     std::deque<Document> inputData() {
         return {DOC("_id" << 0 << "a" << BSONNULL),
                 DOC("_id" << 1),
-                DOC("_id" << 2 << "a" << DOC_ARRAY("a" << "b")),
+                DOC("_id" << 2 << "a" << DOC_ARRAY("a"
+                                                   << "b")),
                 DOC("_id" << 3),
                 DOC("_id" << 4 << "a" << DOC_ARRAY(1 << 2 << 3)),
                 DOC("_id" << 5 << "a" << DOC_ARRAY(4 << 5 << 6)),
ERROR: Code Style does not match coding style

Comment by Martin Bligh [ 29/Jun/15 ]

Doesn't seem like a sane thing to do outside of a BSON doc either.

Comment by Adam Midvidy [ 29/Jun/15 ]

it looks like it applies the formatting rules for printing to an ostream to the BSON macro.

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