From 3466923dc383c60b4764468fe5b39daa8ea16195 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 30 Dec 2018 00:15:06 +1300 Subject: [PATCH] Added rule for trailing comma in enums. --- docs/development/CodingStyle.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/development/CodingStyle.md b/docs/development/CodingStyle.md index 912cd109c68..73874cc06ca 100644 --- a/docs/development/CodingStyle.md +++ b/docs/development/CodingStyle.md @@ -126,6 +126,19 @@ and no space around the '.' and "->" structure member operators. '*' and '&', when used for pointer and reference, shall have no space between it and the following variable name. # typedef +enums that do not have a count or some other form of terminator element shall have a comma after their last element: + +``` +typedef enum { + MSP_RESULT_ACK = 1, + MSP_RESULT_ERROR = -1, + MSP_RESULT_NO_REPLY = 0, + MSP_RESULT_CMD_UNKNOWN = -2, +} mspResult_e; +``` + +This ensures that, if more elements are added at a later stage, only the additional lines show up in the review, making it easier to review. + enums with a count should have that count declared as the last item in the enumeration list, so that it is automatically maintained, e.g.: ```