Wireshark-dev: Re: [Wireshark-dev] Editor config and code formatting
From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Wed, 2 Mar 2022 15:55:50 +0100
Hi, As consistent formatting not always translates into readable formatting (although in many/most cases it does) I’m not in favour of forced automatic formatting. And that is where great freedom comes with great responsibility. I’m already pleased if we can have a consistent style _per file_ I’ve created a mockup once, of a script calling uncrustify while adapting its configuration according to the modelines in the file. It works well, but readability sometimes suffers. My €0.02 > On 1 Mar 2022, at 18:45, David Perry <boolean263@xxxxxxxxx> wrote: > > 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 > ___________________________________________________________________________ > Sent via: Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx> > Archives: https://www.wireshark.org/lists/wireshark-dev > Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev > mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe
- References:
- [Wireshark-dev] Editor config and code formatting
- From: David Perry
- [Wireshark-dev] Editor config and code formatting
- Prev by Date: Re: [Wireshark-dev] Editor config and code formatting
- Next by Date: [Wireshark-dev] First 4 bytes in SNMP application data
- Previous by thread: Re: [Wireshark-dev] Editor config and code formatting
- Next by thread: [Wireshark-dev] First 4 bytes in SNMP application data
- Index(es):