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

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.9.0
    • Internal Code
    • None
    • Fully Compatible
    • Execution Team 2020-10-19

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: