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

Automatic code formatting? #3920

Open
cgbur opened this issue Feb 27, 2024 · 3 comments
Open

Automatic code formatting? #3920

cgbur opened this issue Feb 27, 2024 · 3 comments

Comments

@cgbur
Copy link
Contributor

cgbur commented Feb 27, 2024

I tried searching on the issues page, but couldn't find anyone who mentioned it, so I figure I would.

Has it been considered to add an automatic code formatter and guidelines in the contributing and a formatter configuration to the repository? I know I have had problems in the past where I've had to disable my editor's auto-formatting and manually adjust code format when working in the repository. Perhaps something like clang-format or a suitable alternative? At this point, it would be a pretty massive git diff that would destroy the blame, so it may be too late if preservation is a priority.

This is what sparked my question, as a CI/CD checker would prevent it: #3917 (comment)

Obviously, this project has done well without it, so "no" is a perfectly acceptable answer as well 🙂

@Cyan4973 Cyan4973 self-assigned this Feb 27, 2024
@Cyan4973
Copy link
Contributor

"Considering" is the right label.
We are not against it, and clang-format is probably the way to go.
But taking the time to decide a formatting convention and then apply it to the whole project, accept the blame history impact along the way, is a non-negligible investment, that has proven hard to prioritize so far.

@Cyan4973 Cyan4973 removed their assignment Mar 10, 2024
@andrewblum
Copy link

Hi @Cyan4973 . For the git blame history impact, have you considered adding a .git-blame-ignore-revs file? You can list the commit hashes you want ignored from git blame in there for commits such as running a format for the first time and they won't show up on Github or anything using git blame. I'd be happy to run format, add this file with that format commit ignored, and a GitHub action to run clang-format on PRs. Can also add a pre-commit hook to run clang-format if you'd like, though I think that should be a separate conversation.

You'd still need to decide on formatting convention, but I feel some formatting is better than none / manual formatting and you can tweak as you go after starting with one of the reasonable built-in styles If you did make a large formatting change in the future, just throw that in the .git-blame-ignore-revs

@Cyan4973
Copy link
Contributor

That's an interesting option. It might do the trick.

In term of formatting convention, I believe we have one now, since we have started using it on other (internal) projects.

Now it's more a matter of finding the time to invest in this project.

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

No branches or pull requests

3 participants