Settings for clang-format

Hi,

While preparing my latest pull request I ran clang-format -i <file> on all the files I had changed, but the GitHub Actions run of clang-format-diff still found extra things that needed to be changed.

I’m running clang-format with the default settings, and I couldn’t see how the GitHub Actions run isn’t doing the exact same.

What settings should we be running clang-format with to match the project’s style and appease the automated check?

There’s a .clang-format file for the project: avogadrolibs/.clang-format at 7468e5ff1aa162d50e9410618423dc38553cb530 · OpenChemistry/avogadrolibs · GitHub

I actually use pre-commit to run clang-format for me, but I can see there’s some file that’s causing issues in the GitHub action. (Perhaps because it’s an older version of clang-format, I don’t know)

https://pre-commit.com/#usage

I’m also wondering if I should look into a GH action that literally runs clang-format and adds the patch to the pull request.

1 Like

One extra way to make it easier for new contributors! :slight_smile:

On a related note, we should think a bit about the clang-format version to use. I’ve been using clang-format v16 (and GitHub is currently using v13… which is potentially the issue).

Any particular version to use? It looks like most current Linux distros are using v16 too.

Well on Tumbleweed I have v19 by default! 13 is the oldest version available to me, so I’d vote for at least a bit newer than that.