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 and checkpatch have contradictory requirements #78214

Open
nordic-krch opened this issue Sep 10, 2024 · 4 comments
Open

clang-format and checkpatch have contradictory requirements #78214

nordic-krch opened this issue Sep 10, 2024 · 4 comments
Assignees
Labels
area: Coding Guidelines Coding guidelines and style bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@nordic-krch
Copy link
Contributor

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:

  • SPACING: space prohibited before that close parenthesis ')' clang-format added space after VAL, in a statement like below
COND_CODE_1(FLAG, (.elem = VAL, ), ())
  • TABSTOP: Statements should start on a tabstop clang-format reformatted macro with code generation in a way that is not accepted by checkpath.

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):

@nordic-krch nordic-krch added the bug The issue is a bug, or the PR is fixing a bug label Sep 10, 2024
@pdgendt
Copy link
Collaborator

pdgendt commented Sep 10, 2024

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

@nordic-krch
Copy link
Contributor Author

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
Copy link
Contributor Author

If it's not recommended to run clang-format on entire existing file (#78179 (comment)) 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?

Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Coding Guidelines Coding guidelines and style bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

5 participants