Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-91534

clang-format is hostile toward BSON() literals

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • SP Prioritized List

      Deprecate and replace the "BSON literal" syntax with something other than an even-odd-toggling operator<<. Currently clang-format has no idea how to break these chains into pairs, and humans have a hard time counting the elements to determine what the resulting structure is.

      Example:

                  BSON("aggregate" << collName << "cursor" << BSONObj{} << "pipeline"
                                   << BSON_ARRAY(BSON("$collStats"
                                                      << BSON("storageStats" << BSON(
                                                                  "waitForLock" << false << "numericOnly"
                                                                                << true)))))),

      This kind of thing becomes a completely different arrangement if it's indented, etc, so it's also a churn generator.

      I'm certain we can produce a more fluent builder syntax that clang-format will be able to understand and format as proper hierarchical subexpression groupings.

            Assignee:
            Unassigned Unassigned
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: