arbor-sim / arbor

The Arbor multi-compartment neural network simulation library.
https://arbor-sim.org
BSD 3-Clause "New" or "Revised" License
108 stars 61 forks source link

Auto-Formatting #2248

Open thorstenhater opened 8 months ago

thorstenhater commented 8 months ago

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.

halfflat commented 8 months ago

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.

thorstenhater commented 8 months ago

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.

halfflat commented 8 months ago

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

thorstenhater commented 8 months ago

It seems a saner alternative to clang-format.

Helveg commented 8 months ago

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