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

Add clang tidy rules to prevent const return by value and (in declarations) const pass by value

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • Execution Team 2020-10-19

      There are parts of the codebase that suffer fromĀ const return by value and const pass by value.

      These can be caught by clang tidy, and we would like to add rules to do so. This and this are two clang tidy rules that could help us do so.

      However, there is one issue to watch out for:
      A const qualifier is often used on a pass-by-value param in the implementation file (here's an example). This is a readability enhancement. The reader of the function will now know that the function will not touch modify that param. This usage of the const qualifier shouldn't be flagged.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: