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

clang-format: set ColumnLimit to 0 and reformat #1045

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from

Conversation

mkmkme
Copy link
Contributor

@mkmkme mkmkme commented Sep 18, 2024

This commit hopefully improves the formatting of the codebase by setting ColumnLimit to 0 and hence stopping clang-format from trying to put as much stuff in one line as possible.

This change enabled us to remove most of clang-format off directives and fixed a bunch of lines that looked like this:

#define KEY \
    VALUE /* comment */

Additionally, one pair of clang-format off / clang-format on had clang-format off as the second comment and hence didn't enable the formatting for the rest of the file. This commit addresses this issue as well.

Please tell me if anything in the changes seem off. If everything is fine, I will add this commit to .git-blame-ignore-revs later.

This commit hopefully improves the formatting of the codebase by setting
ColumnLimit to 0 and hence stopping clang-format from trying to put as
much stuff in one line as possible.

This change enabled us to remove most of `clang-format off` directives
and fixed a bunch of lines that looked like this:

```c
\#define KEY \
    VALUE /* comment */
```

Additionally, one pair of `clang-format off` / `clang-format on` had
`clang-format off` as the second comment and hence didn't enable the
formatting for the rest of the file. This commit addresses this issue as
well.

Signed-off-by: Mikhail Koviazin <mikhail.koviazin@aiven.io>
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 98.23529% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.64%. Comparing base (ba71c7e) to head (c0afd62).
Report is 1 commits behind head on unstable.

Files with missing lines Patch % Lines
src/t_string.c 98.60% 2 Missing ⚠️
src/sentinel.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1045      +/-   ##
============================================
+ Coverage     70.62%   70.64%   +0.01%     
============================================
  Files           114      114              
  Lines         61672    61682      +10     
============================================
+ Hits          43555    43574      +19     
+ Misses        18117    18108       -9     
Files with missing lines Coverage Δ
src/acl.c 88.89% <ø> (ø)
src/asciilogo.h 100.00% <ø> (ø)
src/config.c 78.69% <ø> (ø)
src/eval.c 56.54% <ø> (ø)
src/functions.c 95.59% <ø> (ø)
src/latency.c 79.84% <ø> (ø)
src/module.c 9.64% <ø> (ø)
src/networking.c 88.42% <100.00%> (+<0.01%) ⬆️
src/object.c 78.65% <ø> (ø)
src/server.c 88.66% <100.00%> (+0.06%) ⬆️
... and 7 more

... and 12 files with indirect coverage changes

@bjosv
Copy link
Contributor

bjosv commented Sep 18, 2024

Nice.
Its a bit annoying that clang-format had some formatting changes somewhere between 18.1.3 and 18.1.6. Maybe that the reason for the failing CI check?
The check seem to use clang-format 18.1.8.

@hpatro hpatro requested a review from PingXie September 18, 2024 18:59
Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

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

IMO this makes clang-format much less annoying. It lets us remove the /* clang-format off */ which is a good indication that it respects our style better.

ColumnLimit: 0 lets the programmer decide where to make line breaks, right? This seems more practical. Clang-format can help with other things.

@PingXie @madolson WDYT?

Comment on lines +45 to 50
#define AE_BARRIER \
4 /* With WRITABLE, never fire the event if the \
READABLE event already fired in the same event \
loop iteration. Useful when you want to persist \
things to disk before sending replies, and want \
to do that in a group fashion. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it reject it if we would do like this?

Suggested change
#define AE_BARRIER \
4 /* With WRITABLE, never fire the event if the \
READABLE event already fired in the same event \
loop iteration. Useful when you want to persist \
things to disk before sending replies, and want \
to do that in a group fashion. */
#define AE_BARRIER 4 /* With WRITABLE, never fire the event if the \
READABLE event already fired in the same event \
loop iteration. Useful when you want to persist \
things to disk before sending replies, and want \
to do that in a group fashion. */

I was most likely like this originally before clang-format changed it to the worse...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, that's my mistake, I've overlooked it. It will not reject it, I'll fix it :)

src/atomicvar.h Outdated Show resolved Hide resolved
@mkmkme
Copy link
Contributor Author

mkmkme commented Sep 19, 2024

Nice. Its a bit annoying that clang-format had some formatting changes somewhere between 18.1.3 and 18.1.6. Maybe that the reason for the failing CI check? The check seem to use clang-format 18.1.8.

Yeah, good point. I forgot to pin the clang-format version when making this change.

Basically I would suggest pinning the clang-format version both in CI and in the documentation (and for developers) because it changes within the patch versions (there will be a difference between 18.1.3 and there is a difference between 18.1.6 and 18.1.8)

Signed-off-by: Mikhail Koviazin <mikhail.koviazin@aiven.io>
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