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

Format code using clang-format #20524

Open
ThanHenderson opened this issue Nov 6, 2024 · 1 comment
Open

Format code using clang-format #20524

ThanHenderson opened this issue Nov 6, 2024 · 1 comment

Comments

@ThanHenderson
Copy link
Contributor

ThanHenderson commented Nov 6, 2024

This issue stands as proposal to automate code formatting throughout the OpenJ9 codebase, using a tool like clang-format.

On the OMR side, work is being done towards automated formatting using clang-format with integration into the CI pipeline. This current proposal builds off that work and a previous OMR proposal.

Both of those issues contain valuable discussions that are worth reading, and much of it applies here. Without belabouring the points made therein, here are what I believe to be benefited the most by using such a tool:

Reading

  • Automated formatting produces more readable code; one knows what to expect. The selected format likely will not be anyone's favourite, but it will at least be enforced consistently.

Writing

  • One need not spend time to ensure proper formatting manually. clang-format integrates well with IDEs and editors to format-on-save, and if not integrated, can be simply run from the command line, and easily integrated into a CI pipeline.

Reviewing

  • An automated formatting tool reduces reviewer and author overhead by removing virtually all formatting related comments, allowing the review to focus on semantics of the proposed change, speeding up the reviewing/addressing cycle, and reducing the time-to-merge.

Goals

  • Format the C/C++ codebase in its entirety, or a selected set of directories, using clang-format
  • Add automation via GitHub hooks to validate code format of every commit within a PR
  • Provide optional git hooks that enable automatic formatting of a git commit
  • Provide instructions on setting up clang-format on the most popular code editors (VSCode, vim/nvim, emacs, eclipse, etc.)
  • Minimize spending reviewer/author resources on any stylistic PR comments and allow us to focus on the semantics of the patch

This issue will serve as a forum of discussion and sharing opinion. Feel free to voice concerns, support, and suggestions.

Copy link

github-actions bot commented Nov 6, 2024

Issue Number: 20524
Status: Open
Recommended Components: comp:build, comp:vm, comp:test
Recommended Assignees: keithc-ca, adambrousseau, tajila

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants