Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a little commit to add the clang-format config, but also can serve as a discussion point for formatting in the FS code.
Currently, the code is a nasty mix of tabs and spaces — which can look terrible with if you have the wrong tabstop set — as well as a mix of styles from various decades and generations of authors.
We've discussed adding style guides in other channels before, but to reiterate: a philosophy I've grown to appreciate from the Go community is that code is read many more times than it is written, and readability counts.
It's much easier to parse someone else's code, or more commonly your own a few months or years later, if it follows a consistent pattern. The style minor details of the style don't really matter that much, but consistency does. Auto-formatters take some drudgery out maintaining a consistent style and, I find, also make writing code faster as you don't have to worry about some parts of style at all. Especially so if you set up your editor to format on write.
For Python code, I suggest we use black. It doesn't need any config. For Go, there's
gofmt
built into the distribution.This then leads to the real discussion point we need to settle. I think there're two options (though they're not mutually exclusive):
git blame
but there are ways around this.Anyway, that's the blurb, here's the
clang-format
style. I've typically used this in new C code I've written. I'm happy to compromise on minor details (e.g. tabs for indentation or not) but the end goal is consistency. Adding this config into the root of the source tree allowsclang-format
to find and apply it. I suggest adding a plugin into your favourite editor, such as autoformat, to runclang-format
automatically if using approach 2., or at least use clang-format as a formatter for code blocks if using approach 1.