Wireshark-dev: [Wireshark-dev] Editor config and code formatting

From: David Perry <boolean263@xxxxxxxxx>
Date: Tue, 1 Mar 2022 12:45:16 -0500
Hi all,

Bottom line up front: how much do people care about the formatting of Wireshark's source code?

Background: I'm looking into [#17253][1]. It's chiefly about removing editor modelines from the footer of each source file in favour of just using `.editorconfig` files. But by extension it's also about removing the exceptions from `.editorconfig` files and making the formatting rules consistent across files.

I took a manual pass at harmonizing the formatting of the C files in the root of the repo and that was painful, so I researched automatic approaches for the rest of our code. [Clang-Format][2] seems to be a popular approach for this sort of thing.

Automatic code formatters in general, and clang-format in particular, are rigid and somewhat naïve in how they do things. This is in contrast to the flexible formatting practices we use. That's not a huge deal if we just want to reformat once to harmonize our indentation levels and whatnot, and then return to manually formatting based on the new standard.

On the other hand, a comment on !6298 suggested that automatic reformatting could be integrated as a pre-commit hook and/or a CI step. That... also isn't a huge deal, I guess. We'd have consistency across files at the price of slightly less formatting freedom. (And of having another developer prerequisite to install, if we did it as a pre-commit hook.)

But it's a decision that should be made by the dev community as a whole. So what do you folks think? Is consistent formatting important to you? Would you like to see it enforced with an automatic formatter?

(My proposed `.clang-format` file is in [!6298][3] and aims to capture the most common practices used across the codebase. Please use that MR for discussions about specific formatting details. This email is for the general discussion of whether/how to apply and enforce formatting.)

Thanks for your time,

David Perry
he/him

[1]: https://gitlab.com/wireshark/wireshark/-/issues/17253
[2]: https://releases.llvm.org/13.0.1/tools/clang/docs/ClangFormat.html
[3]: https://gitlab.com/wireshark/wireshark/-/merge_requests/6298