Skip to content

Add code formatting infrastructure#397

Open
matt-gretton-dann wants to merge 6 commits into
masterfrom
matt-gretton-dann/clang-format
Open

Add code formatting infrastructure#397
matt-gretton-dann wants to merge 6 commits into
masterfrom
matt-gretton-dann/clang-format

Conversation

@matt-gretton-dann

Copy link
Copy Markdown
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.
@matt-gretton-dann matt-gretton-dann force-pushed the matt-gretton-dann/clang-format branch from cecd109 to 9ac2541 Compare June 18, 2020 14:32
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.
@matt-gretton-dann matt-gretton-dann force-pushed the matt-gretton-dann/clang-format branch from 9ac2541 to 5648898 Compare June 18, 2020 14:44
@zlatanvasovic

Copy link
Copy Markdown
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.

Comment thread .clang-format
ColumnLimit: 100
IndentWidth: 2
Language: Cpp
Standard: Cpp11

Copy link
Copy Markdown
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.

3 participants