liquidaty / zsv

zsv+lib: tabular data swiss-army knife CLI + world's fastest (simd) CSV parser
MIT License
201 stars 11 forks source link

Automate source code formatting with `clang-format` #185

Open iamazeem opened 1 month ago

iamazeem commented 1 month ago

Hi,

To automate the source code formatting and to keep it consistent throughout, clang-format can be configured for zsv:

https://zed0.co.uk/clang-format-configurator/ may be used to generate the .clang-format file. Once .clang-format is added, the users can configure their editors, e.g. VS Code, to format source files automatically (on demand or on save).

The same can be integrated in the CI pipeline as well to enforce a consistent style. The CI may fail if code is not formatted or it can reformat and commit the formatted files back to repo. LMK what would be the preferred workflow. I'll update the CI accordingly.

Thanks!

liquidaty commented 1 month ago

Will review and comment shortly

liquidaty commented 1 month ago

Is it possible to start with CI failing if changed code does not conform-- but only for changed code? If so, let's do that.

If not, can we start with having the CI fail if code does not conform, but only for certain specified files? If so, let's do that, starting with src/*.*. We can broaden the scope later.

If none of the above is feasible, will review further and get back to you.

iamazeem commented 1 month ago

Both are feasible.

However, I'll recommend to create one single PR first with formatted source code in one go excluding externals libs. After that, it'll just be the conformance of the new code only.