-
Notifications
You must be signed in to change notification settings - Fork 58
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 #126
base: master
Are you sure you want to change the base?
Clang format #126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be generally positive on reformatting the code with more consistent styling. Even if this is not qt code, we've been roughly following those conventions. E.g. indent of 4, no hard tabs etc. Style here mostly good, but noticed some cases where old code was nicer.
What I'm not sure of is having hooks on clang as in my experience that sort of tooling might be too easily complaining on code details that are perfectly fine, like forcing specific line wrapping etc. Elsewhere we've cleaned up messes by running a formatting tool just once and after that people honoring the conventions better. We could start by just doing the same thing here.
Also now the commits are having some changes a bit back and forth.
: mReachedEOS(false), | ||
mReading(false) { | ||
} | ||
AsyncCodecSource::Output::Output() : mReachedEOS(false), mReading(false) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer here the init list separate and wouldn't like folding the {} body to the line.
droidmediacodec.cpp
Outdated
if (m_framesReceived.buffers.size() < DROID_MEDIA_CODEC_MAX_INPUT_BUFFERS) { | ||
m_framesReceived.buffers.push_back(buffer); | ||
m_framesReceived.cond.signal(); | ||
m_framesReceived.lock.unlock(); | ||
|
||
return; | ||
} | ||
// either get() will signal us or we will be signaled in case of an error | ||
// either get() will signal us or we will be signaled in case of an | ||
// error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like relatively short line length being forced here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I had comment reflow enabled together with a 80 char column limit, fixed, will look for other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we converged on the parameters to use I will rerun the formatting and create a fresh set of commits not containing this
services/services_8_1_0.h
Outdated
void noteStopCamera(int uid) { } | ||
void noteResetCamera() { } | ||
void noteResetFlashlight() { } | ||
void noteStartSensor(int uid, int sensor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep empty functions on one line?
You mean to check if the rules where applied? Hooks can be run on the developer side to check if code follows the rules a shown e.g. in:
I think Clang 12 is to old if it does limit us. |
I found there is actually a clang-format file for Qt with BSD license and applied it. Need to clean up the history ... |
The KDE Clangformat file has been quite useful. In my project below I'm using those hooks. |
Clang-format configuration can be adjusted per project or optionally per project type e.g. Qt projects. As the formatting in specific sections can be disable hooks should be always on, unless the commiter tells git to not do so, without it easy for new contributors to miss following the formatting rules. You add disable formatting for specific section by inserting:
as shown below: |
I experimented a bit with adding clang-format to this repo. The code is unfortunately formated quite creatively so I was not able to decide what is likely the desired formatting. Please feel invited to comment as much as you like and I'll try to improve the settings.
Or do you have an internal clang format file already?
I choose clang-format-12 as that should be available on both Ubuntu 20.04 and 22.04 but if that is not what you use at Jolla I can also propose another version.
I added pre-commit.com which can be configured to run before any commit conveniently. This way your commits will always be clean.
I then formatted the code with some example settings and added the commit hash to
.git-blame-ignore-revs
. Some git blame tools understand this and won't show the formatting in blames.Finally I added github ci to run this online in case contributors do not locally.
run for all files with
or just have it complain & format once you
git commit