Modernize clang-format: enforce 120-column limit and reduce config to meanful overrides#2
Modernize clang-format: enforce 120-column limit and reduce config to meanful overrides#2harrylin98 wants to merge 2 commits into
Conversation
Signed-off-by: harrylin98 <harrylin980107@gmail.com>
Signed-off-by: harrylin98 <harrylin980107@gmail.com>
JimB123
left a comment
There was a problem hiding this comment.
I added a few comments/notes. I just scanned files up to cluster_legacy.
Overall, I think many of the changes are neutral. Some of them are really good. A few are seem negative.
If I had to guess regarding TSC feedback, I think they'll probably nitpick the things that they don't like, and dismiss the rest as mostly neutral.
For me, I think that overall it's an improvement.
| "dataset changes will be retained.", | ||
| 0, | ||
| abortCommandHandler, | ||
| lua), |
There was a problem hiding this comment.
This section isn't great. Between the expansion to multi-lines, and the shifting due to string size, I think this might generate push back.
| size_t *commands_len) { | ||
| VALKEYMODULE_NOT_USED(module_ctx); |
There was a problem hiding this comment.
This blends the function contents into the parameters.
Personally, I can live with this, but I'd rather see something like:
static int fn (
int p1,
int p2) { // indented 8 to avoid blending with code
// code begins (indented 4)There was a problem hiding this comment.
Can we try ContinuationIndentWidth set at 8? Will this fix this?
| case LUA_TSTRING: | ||
| ValkeyModule_ReplyWithStringBuffer(ctx, lua_tostring(lua, -1), lua_strlen(lua, -1)); | ||
| break; | ||
| case LUA_TSTRING: ValkeyModule_ReplyWithStringBuffer(ctx, lua_tostring(lua, -1), lua_strlen(lua, -1)); break; |
There was a problem hiding this comment.
I think this one is a negative. I like the original better.
Maybe if ALL of the case branches could fit like this, but it's inconsistent.
| if (ValkeyModule_CreateCommand(ctx, "hellocluster.pingall", PingallCommand_ValkeyCommand, "readonly", 0, 0, 0) | ||
| == VALKEYMODULE_ERR) | ||
| return VALKEYMODULE_ERR; |
There was a problem hiding this comment.
This is similar to my comment about function parameters. It bends the IF continuation with the next line.
Ideally, I'd do this
| if (ValkeyModule_CreateCommand(ctx, "hellocluster.pingall", PingallCommand_ValkeyCommand, "readonly", 0, 0, 0) | |
| == VALKEYMODULE_ERR) | |
| return VALKEYMODULE_ERR; | |
| if (ValkeyModule_CreateCommand(ctx, "hellocluster.pingall", PingallCommand_ValkeyCommand, "readonly", 0, 0, 0) | |
| == VALKEYMODULE_ERR) | |
| return VALKEYMODULE_ERR; |
| case ACL_DENIED_DB: | ||
| le->object = argpos ? sdsdup(objectGetVal(c->argv[argpos])) : sdsdup(c->cmd->fullname); | ||
| break; |
There was a problem hiding this comment.
This case is inconsistent, but I personally like the change. I think the original line was just getting too large/complex. IMO this change helps readability.
| #define AE_BARRIER 4 /* With WRITABLE, never fire the event if the \ | ||
| READABLE event already fired in the same event \ | ||
| loop iteration. Useful when you want to persist \ | ||
| things to disk before sending replies, and want \ |
There was a problem hiding this comment.
This change was unexpected. Why did this occur?
| if (rep->type != VALKEYMODULE_REPLY_STRING && rep->type != VALKEYMODULE_REPLY_SIMPLE_STRING | ||
| && rep->type != VALKEYMODULE_REPLY_ERROR) |
| {"client-tls-port", | ||
| auxAnnounceClientTlsPortSetter, | ||
| auxAnnounceClientTlsPortGetter, | ||
| auxAnnounceClientTlsPortPresent}, |
| if (!(flags & (CLUSTER_NODE_FAIL | CLUSTER_NODE_PFAIL)) && nodeInNormalState(node) && node->ping_sent == 0 | ||
| && clusterNodeFailureReportsCount(node) == 0) { |
There was a problem hiding this comment.
This seems worse. Looking at the original, why wasn't that refactored earlier?
This is internal draft PR:
This PR changes the .clang-format configuration and reformats src/* accordingly.
Reformat: The second commit applies the new config across all src/*.{c,h} (122 files). This is a mechanical reformatting with no logic changes.
Config changes: