halfgaar / FlashMQ

FlashMQ is a fast light-weight MQTT broker/server, designed to take good advantage of multi-CPU environments
https://www.flashmq.org/
Open Software License 3.0
173 stars 24 forks source link

Document code style #92

Closed quinox closed 1 month ago

quinox commented 3 months ago

Also run a stylecheck on incoming PRs and reject the PR when the changes lines aren't properly formatted.


To see the effect of the style changes:

sudo apt install clang-format-15
clang-format-15 *.cpp */*.cpp

There's .clang-format (your style) and .clang-format.original (the default config for LLVM style). By running a diff on these two files you can see what deviations you have from the LLVM style, which makes it easier to upgrade the configuration when you want to switch clang-format versions: I tried it out with v17 which has a few new options, and some options changed from booleans to mappings.

The options themselves are documented here


The CI check will only look at the lines that changed, not all lines. This means you're allowed to use whatever style yourself while still demanding PRs to adhere to your documented style.

This is what the CI looks like:

image

halfgaar commented 1 month ago

One thing the style does differently than me, is this:

-void SubscriptionStore::giveClientRetainedMessagesInitiateDeferred(const std::weak_ptr<Session> ses,
-                                                                   const std::shared_ptr<const std::vector<std::string>> subscribeSubtopicsCopy,
-                                                                   std::shared_ptr<std::deque<DeferredRetainedMessageNodeDelivery>> deferred,
-                                                                   int &requeue_count, uint &total_node_count, uint8_t max_qos)
+void SubscriptionStore::giveClientRetainedMessagesInitiateDeferred(
+    const std::weak_ptr<Session> ses, const std::shared_ptr<const std::vector<std::string>> subscribeSubtopicsCopy,
+    std::shared_ptr<std::deque<DeferredRetainedMessageNodeDelivery>> deferred, int &requeue_count, uint &total_node_count, uint8_t max_qos
+)

I'm not sure yet what I like better.

Anyway, it looks like a nice autocratic way to force the rules on others, so I rebased+merged it :).