Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code formatting infrastructure #397

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

matt-gretton-dann
Copy link
Collaborator

This PR adds a .clang-format file to format code at the top-level and enforces it using a GitHub Action.

On Windows modern versions of Visual Studio should pick up the .clang-format file as well and automatically format code when saved.

The formatting choices made are based on Microsoft's defaults for Visual Studio. Of interest though will be the choices between tabs & spaces, indent width and max line length.

I have chosen tabs with an indent of 2 spaces per-tab. This is what we've had previously, but I'm interested in any other thoughts @NeilFerguson, @dlaydon, @weshinsley.

On line length - I've picked 100, as that is what the Linux Kernel has recently moved to, and my view is that I start losing context on longer lines. Again up for discussion.

Matthew Gretton-Dann added 4 commits June 18, 2020 15:32
This adds a workflow that will automatically clang-format any code on a
pull_request.
This is the automatic part of applying clang-format.  Not everything may
build yet.
Matthew Gretton-Dann added 2 commits June 18, 2020 15:44
Clang format rearranged some of the header includes which highlighted
some build issues.
The clangformat auto-applied patch produced some untidily formatted
comments.  This commit tidies up the ones I spotted.
@zlatanvasovic
Copy link
Contributor

As I said in the previous thread: tabs make changelogs look bad by default and thus require additional user work. Unless you customize the tab size in Git diffs, they won't be displayed as you intended.

ColumnLimit: 100
IndentWidth: 2
Language: Cpp
Standard: Cpp11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't Standard be Cpp14?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants