-
Notifications
You must be signed in to change notification settings - Fork 89
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
Formatting #799
base: oe_port
Are you sure you want to change the base?
Formatting #799
Conversation
Signed-off-by: Christoph M. Wintersteiger <[email protected]>
I think everything in src should be formatted with the clang-format thing. It's really annoying trying to review diffs where people have mixed formatting changes in with real changes and we have several people that don't read their diffs before committing so end up including formatting changes. |
Great, I'll format all of the files then and look into adding a commit hook! |
Signed-off-by: Christoph M. Wintersteiger <[email protected]>
Signed-off-by: Christoph M. Wintersteiger <[email protected]>
@letmaik had already set the hooks up, thanks! This enables them and src/* is auto-formatted. |
@wintersteiger Thanks for doing this, there's just one more thing missing to also enable it in CI, see the scripts/check-ci script. Looking at the CI logs there also seem to be some unformatted files still, probably tests. |
If we're going to enable this in CI (and I recommend that we do), please also add a build-system target that runs the same command that CI runs to check. |
@davidchisnall Currently we use a git pre-commit hook to run the checks. Adding a build system target would allow you to run the checks before trying to commit. It's the same though as just running |
Does the pre-commit hook fix the issue? If so, I'm happy. If not, if contributors get an error trying to commit and the instructions are any more complex than 'run this build target to fix the issue' then we're adding annoying levels of friction for new contributors. It's also annoying that the pre-commit hooks depend on some Python goo. I didn't notice this when they went in (I thought they were just linting for the Python code, not something everyone runs on every commit) and so I got weird failures that I didn't have some Python packages installed the next time I tried to commit after pulling them down, which made me cranky. |
@davidchisnall I understand your concerns and we can definitely change this. The default was to just do what OE does. We can also do what CCF does if that fits us better (no pre-commit hook, but CI checks in a separate job that doesn't block early testing while formatting isn't right yet, plus a notice in CI to run command xyz to fix issues / run the linter). |
Snmalloc also does the latter, and it's much easier for new contributors: if CI fails in the formatting step, they're told 'run ninja clang-format in your build directory and commit the changes' and then everything works. It would be even nicer if CI could do that commit for you in CI jobs... |
If everyone agrees, then this is what's missing here:
If think for now, auto-committing in CI is too much, especially because most linter failures can't be auto-corrected. |
That sounds great, thanks @letmaik! And yes, I think I didn't format the tests. |
This fixes a few code formatting violations in recently added code. Many of the header files are also not formatted correctly (not fixed here). Do we have consensus on the style and can we start to enforce it?
It's impossible for me to tell which files are supposed to be OE-formatted which one's aren't. Can someone mark those by adding clang-format exceptions at the top of those files or give me a list of files so I can add them?