Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-8713

Update DM C++ Style Guide to enable automatic code layout with clang-format

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Story Points:
      0.5
    • Team:
      Data Release Production

      Description

      Implements RFC-261. Update DM C++ Style Guide (primarily section 6) to enable automatic code layout with clang-format.
      This involves adding a version controlled LSST clang-format style that is as much as possible compliant with the current layout rules. And subsequently removing or modifying the existing layout rules to be compliant with the output created by clang-format using this style.

      The intended end result is that users can simply run clang-format (with the LSST provided style) to automatically fix all C++ code layout issues.

      Users are still free to not use clang-format as long as the output looks the same.

        Attachments

          Issue Links

            Activity

            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            Kian-Tat Lim Ok, I think it is ready.

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - Kian-Tat Lim Ok, I think it is ready.
            Hide
            rowen Russell Owen added a comment - - edited

            Two minor notes. Pim Schellart [X] has already said this, but I hope we are willing to allow spaces around * and / because I think clang-format will insist on it. Also, clang-format in google style does unpredictable things with &, e.g. it sometimes adds a space afterwards and sometimes does not, and it may break a line between the & and the next item (I noticed this often when formatting pybind11 wrappers). I am not complaining or saying we should change anything, I am just hoping our standards will be loose enough to tolerate these issues. I am very much in favor of automatic formatting!

            Show
            rowen Russell Owen added a comment - - edited Two minor notes. Pim Schellart [X] has already said this, but I hope we are willing to allow spaces around * and / because I think clang-format will insist on it. Also, clang-format in google style does unpredictable things with & , e.g. it sometimes adds a space afterwards and sometimes does not, and it may break a line between the & and the next item (I noticed this often when formatting pybind11 wrappers). I am not complaining or saying we should change anything, I am just hoping our standards will be loose enough to tolerate these issues. I am very much in favor of automatic formatting!
            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            We will have to allow spaces, otherwise we cannot use clang-format, but the question is do we make them optional or mandatory?

            As for the `&`, clang-format follows the Google rules, which allows it to be attached either to the type or the variable. I don't think we have any rule that conflicts with this behaviour.

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - We will have to allow spaces, otherwise we cannot use clang-format , but the question is do we make them optional or mandatory? As for the `&`, clang-format follows the Google rules, which allows it to be attached either to the type or the variable. I don't think we have any rule that conflicts with this behaviour.
            Hide
            ktl Kian-Tat Lim added a comment -

            Relatively minor suggestions on the PR. I'm sorry this has taken a long time, but I hope people are reasonably pleased with the result.

            Show
            ktl Kian-Tat Lim added a comment - Relatively minor suggestions on the PR. I'm sorry this has taken a long time, but I hope people are reasonably pleased with the result.
            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            Merged after changes.
            Thanks! I'm very happy that I can now use clang-format!

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - Merged after changes. Thanks! I'm very happy that I can now use clang-format !

              People

              Assignee:
              pschella Pim Schellart [X] (Inactive)
              Reporter:
              pschella Pim Schellart [X] (Inactive)
              Reviewers:
              Kian-Tat Lim
              Watchers:
              Jim Bosch, John Parejko, John Swinbank, Kian-Tat Lim, Krzysztof Findeisen, Pim Schellart [X] (Inactive), Russell Owen, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.