penguineer / mqtt-tools

A library to simplify agents that react on/with external events or MQTT messages by handling 95% of the MQTT use-cases.
Other
2 stars 1 forks source link

Set a policy on whitespace use and enforce it #11

Open LeSpocky opened 6 years ago

LeSpocky commented 6 years ago

Currently indentation is done by mixed tabs and spaces and different indentation levels (2 spaces, 4 spaces, …). Choose one policy and stick to it, maybe with editor modelines.

penguineer commented 6 years ago

How about defining a clang-format file and have a hook check all commits against the format? (With an additional make target to apply the format to all changes.)

LeSpocky commented 6 years ago

Never heard about clang format files, but a hook checking would certainly lead to more consistent results.

penguineer commented 6 years ago

About clang-format: https://clang.llvm.org/docs/ClangFormat.html Also available in Debian: https://packages.debian.org/stretch/clang-format-3.8

The level of checking/corrections can be specified in the formats file. We use this at work to check consistency with our Coding Guidelines.

LeSpocky commented 6 years ago

So first step would be to specify this formats file or someone picks an existing one, we can agree on. This would already allow to add new code in the desired format, even without a repository hook.

penguineer commented 6 years ago

Just found this: http://cf.monofraps.net/

There are lot of C++ styles out there, but I have not found an explicit C style yet.

We need to consent on a C-based coding style anyways, as there are already different styles in the available code.

penguineer commented 6 years ago

Some more:

A blog article on the topic: https://opensource.com/article/17/1/coding-style