zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.84k stars 6.6k forks source link

clang-format and checkpatch have contradictory requirements #78214

Open nordic-krch opened 2 months ago

nordic-krch commented 2 months ago

Describe the bug

After running clang-format on drivers/serial/uart_nrfx_uarte.c (#78179) I'm getting checkpatch errors.

There are 2 types of errors:

To Reproduce

  1. run clang-format on drivers/serial/uart_nrfx_uarte.c and then run checkpatch
  2. See error

Expected behavior

Running clang-format shall not violate checkpatch rules.

Impact

Red CI after running clang-format. Manual code adjustment must be used which discourage user from using clang-format.

Environment (please complete the following information):

pdgendt commented 1 month ago

FYI clang-format reports checkpatch issues on the "notice" level, these aren't blocking PRs.

nordic-krch commented 1 month ago

yes, but if i run clang-format on a file and commit that I will get red CI because checkpatch reports those as errors. https://docs.zephyrproject.org/latest/contribute/guidelines.html#clang-format suggests to use it. On the other hand it states that

When there are differences between the Coding Style guidelines and the formatting generated by code formatting tools, the Coding Style guidelines take precedence.

but it would be best to configure it in a way so that there are as few differences as possible.

nordic-krch commented 1 month ago

If it's not recommended to run clang-format on entire existing file (https://github.com/zephyrproject-rtos/zephyr/pull/78179#issuecomment-2340255925) then maybe it's worth adding it to the guidelines section about clang-format. It's not clear how to treat those notices left by clang-format in the PR? Is it obligatory to fix them?