-
Notifications
You must be signed in to change notification settings - Fork 225
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
Code: Use clang-format 13 #2559
Conversation
We currently use clang-format 10 which has shown to produce unexpected output. This is annoying for PR submitters as the CI forces non-optimal code layout, especially when submitters use a later clang-format version which does not show this behavior. This commit changes CI to use clang-format 13 and updates relevant clang-format inline docs. This also updates the version of the Github Action to the latest version as this is required for v13 support. Related: jamulussoftware#2552
This has the potential to be a pain. Do we know what version of clang-format is included with various distributions of Linux and macOS? Ubuntu 20 has clang-format version 10. Raspbian 11 (the latest) has clang-format version 11. When I was developing on Raspbian 10, which only has clang-format 7, it was annoying to have to push on the Pi, fire up an Ubuntu 20 VM, pull to it, do clang-format and push back the changes. It became much nicer when I switched to Raspbian 11, as I could do clang-format natively. Moving to a requirement of clang-format 13 would be a backward step for me. I suppose I might be able to install a newer clang-format from source, but I prefer to use what is packaged with the distro. |
NOTE: I had not read the issue #2552 when I typed the above. I'm still not keen. |
I understand that regarding the consequences (worsened situation for many Linux users) and I agree that we should try to avoid that. I think this was the main reason for choosing a rather conservative clang-format version when first introduced. However, if we don't update, the only other alternatives I can think of are adding workarounds for wrongly-formatted code or merging PRs despite red warnings (we might be able to reduce the checks to the files which are modified in a PR, though). Do you have any other ideas? |
I haven't encountered any formatting issues yet, and have not studied the examples mentioned in the issue. Has it been determined whether the observed issues are fixed in 11, 12 or 13? |
Maybe if clang-format fails in CI it could raise a PR on the contributor's repo for the required changes? I don't know how hard that would be, or even if it's possible. |
The one we've pinpointed exactly (pointer receivers) is fixed in 13. This has already been relevant in a PR by @pgScorpio so far and not on
I think that's doable, but requires contributors to merge the PR and pull from their own PR (or do it again after the next force push). |
That one looks like clang-format getting confused because of rapid turning off and on of clang-format. I couldn't even tell from scrolling back a bit what the indentation level should be! Is it really necessary to have all possible version compatibility sections un-indented? Might it be better to delimit them with conspicuous special comments instead and allow them to be subject to clang-format indentation? |
I'm not a fan of the un-ident at all, but that's how it is. If there's agreement to change that (@pljones? :)), that would work around this part. |
Hey, I just live here... Uh... In fact, the outdented style for "Look, I'm not normal code, so pay attention" is a bit odd. Having a |
Just some thoughts.... (As we always will have to deal with different clang-format-versions I guess.)
|
Thanks for those suggestions.
This would work for new code, but would be annoying for existing code which might flip back and forth dependening on the PR submitter. This increases diff sizes and makes
Hm, if we go that route I'd rather point to some canonical source to get the binaries. Git repos usually aren't supposed to contain binaries. We'd need to have at least four versions: Linux x86_64, Linux armhf, Windowx 86_64, Mac x86_64. In addition,
Hmm, but I guess this would have the same back-and-forth problem for all non-new files as well? Or would require submitters to have multiple clang-format versions installed in parallel? |
What problems would we expect if we switched to v13 as the authoritive version, but advised users only to clang-format the files which they've touched? I think that's what most editors do anyway. We could then drop That way, the only known formatting conflict in current |
Related: #2600 |
Closing as I think #2600 is a short term fix. As soon as debian stable moves to a more recent Clang format version, we can re-open this. |
Short description of changes
Coding style: Require clang-format 13
We currently use clang-format 10 which has shown to produce unexpected output. This is annoying for PR submitters as the CI forces non-optimal code layout, especially when submitters use a later clang-format version which does not show this behavior.
This commit changes CI to use clang-format 13 and updates relevant clang-format inline docs.
Code: Run clang-format 13 on all source files
CHANGELOG: Code: Updated clang-format version requirement and CI check to v13 due to bugs in v10.
Context: Fixes an issue?
Related: #2552
Does this change need documentation? What needs to be documented and how?
Yes. This necessary documentation update of CONTRIBUTING.md has part of this PR.
Status of this Pull Request
Ready.
What is missing until this pull request can be merged?
Checklist