simdutf / simdutf

Unicode routines (UTF8, UTF16, UTF32) and Base64: billions of characters per second using SSE2, AVX2, NEON, AVX-512, RISC-V Vector Extension. Part of Node.js, WebKit/Safari and Bun.
https://simdutf.github.io/simdutf/
Apache License 2.0
1.11k stars 69 forks source link

discuss: introduce clang format #562

Open pauldreik opened 1 week ago

pauldreik commented 1 week ago

The code is sometimes inconsistently formatted. That does not bother me.

However, when developing, it is very convenient if one can use auto formatting. I also think it leads to cleaner pull requests since unrelated white space changes are less likely to occur. It is also easier for contributors to adhere to the code style without effort (most IDE-s support formatting).

This comes up now when working with the span interface - it would be nice to have some kind of machine enforceable formatting in place before I start.

The established practice is to have a .clang-format checked in at the root level. There is already one for the fuzzer subdirectory.

The downsides:

I suggest to introduce a CI job which checks the formatting. In case there is a formatting failure, the job fails and a suggested diff is output which can be applied with git apply.

The suggestion is:

lemire commented 1 week ago

Sure. E.g., we could adopt the following:

https://github.com/search?q=repo%3Afastfloat%2Ffast_float+clang-format&type=code

My key objection against clang-format in general is that it is clang version dependent. So you must require a fixed version of clang-format. Thankfully, this can be done with docker.

Pull request invited.