arbor icon indicating copy to clipboard operation
arbor copied to clipboard

Auto-Formatting

Open thorstenhater opened this issue 2 years ago • 5 comments

Hi all,

let's make our lives a bit easier and use an auto formatter. So, decision time.

Zero: Do we?

If we go for it, we'll have to stick with it, make some compromises on style, and accept a potentially humongous PR with all the initial change. The payoff is the peace of mind of never having to care again.

First: How?

Based on the lay of land the only real options are clang-format and uncrustify. The former is tricky to use and realistically must be pinned to one version.

Second: What?

This is the hard part. Once we have decided on a tool, we'll go through all the options and pick those we like best, collectively.

thorstenhater avatar Jan 16 '24 13:01 thorstenhater

I've always been against it as you know, primarily because it adversely affects readability of mathematical expressions. But I also acknowledge that my opinion should carry little weight given that I'm contributing very little.

That said, I will also continue to claim that it is a very low burden to contribute code in the house style, whether that aim be accomplished by hand or with the assistance of local tools.

halfflat avatar Jan 16 '24 14:01 halfflat

Sure, your concerns are valid and input is always welcome. Have you taken a look at uncrustify? I know of your earlier spat with clang-format, but here might a light at the end of the tunnel:

#
# Spacing options
#

# Add or remove space around non-assignment symbolic operators ('+', '/', '%',
# '<<', and so forth).
sp_arith                        = ignore   # ignore/add/remove/force/not_defined

# Add or remove space around arithmetic operators '+' and '-'.
#
# Overrides sp_arith.
sp_arith_additive               = ignore   # ignore/add/remove/force/not_defined

I noted the willingness to compromise as a requirement above. The trade-off is that we'll all get 80%+ of what we want of a style, but we also never have to nit anyone else in review for slight deviation of the perceived correct formatting.

thorstenhater avatar Jan 18 '24 08:01 thorstenhater

Ahah! I will take a closer look at uncrustify — my concerns may well now be moot.

halfflat avatar Jan 18 '24 11:01 halfflat

It seems a saner alternative to clang-format.

thorstenhater avatar Jan 18 '24 11:01 thorstenhater

For Python I would recommend black (with a longer line length) and isort.

Helveg avatar Jan 30 '24 08:01 Helveg