Repository navigation
Move node endpoint handlers out of NodeEndpoints::init_handlers - #8491
Merged
Amaury Chamayou (achamayou) merged 1 commit intoOct 2, 2026
Merged
Amaury Chamayou (achamayou) merged 1 commit into
Amaury Chamayou (achamayou) merged 1 commit into
Conversation
Max (maxtropets)
approved these changes
Oct 2, 2026
Refactor ccf::NodeEndpoints::init_handlers() in src/node/rpc/node_frontend.h following the member-function convention from #8489: each [this] handler lambda body becomes a private member function (templated where the lambda was generic), with a thin forwarding lambda left in place for registration. Capture-less handlers (version, service_previous_identity) become private static member functions. No naming clashes were found against CommonEndpointRegistry/BaseEndpointRegistry/EndpointRegistry or free functions, so all 32 handlers keep their original names. Removes the NOLINTNEXTLINE(readability-function-cognitive-complexity) above init_handlers(). Cognitive complexity drops from 266 (all contributed by the 24 inline handler lambdas) to effectively 0 for the new init_handlers(); the largest extracted function (accept) measures 38, well under the threshold of 50. Non-move changes, all required because some clang-tidy checks skip lambda bodies but apply once the code is a real named function: - 20 unnamed trailing nlohmann::json&& parameters given a /*params*/ comment name (readability-named-parameter). - 5 NOLINT(bugprone-unchecked-optional-access) added at pre-existing unchecked optional accesses now visible to the checker; placed as NOLINTNEXTLINE immediately above the flagged expression to match clang-tidy's diagnostic location for these multi-line statements. - 2 redundant trailing `return;` statements removed from get_ready_app and get_ready_gov (readability-redundant-control-flow), matching the precedent set in file_serving_handlers.h. Verified as a pure reshuffle with a script that strips comments/whitespace from each old lambda body and new function body and requires exact equality after applying only the explicit edit list above; all 33 units match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Amaury Chamayou (achamayou)
force-pushed
the
achamayou-supreme-guide
branch
from
October 2, 2026 13:24
c222da8 to
d4b3a42
Compare
Amaury Chamayou (achamayou)
merged commit Oct 2, 2026
058f585
into
achamayou-studious-guide
12 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Part of #7358. This is layer 6 of a 7-PR stack, on top of #8489.
ccf::NodeEndpoints::init_handlers()insrc/node/rpc/node_frontend.hscored a cognitive complexity of 266, all of it contributed by its 24 inline[this]handler lambdas.Implementation summary
Each handler lambda body becomes a private member function with the same name and parameter list, following #8489's member-function convention; registration keeps a thin forwarding lambda.
Generic lambdas became member function templates with the same deduced
autoreturn type; concrete-typed ones stayed concrete; the two capture-less handlers (version,service_previous_identity) became private static member functions.Naming rule: no clashes were found against
CommonEndpointRegistry/BaseEndpointRegistry/EndpointRegistryor free functions, so all handlers kept their original names unchanged.Complexity:
init_handlers()266 -> effectively 0 (pure forwarding calls); largest extracted function (accept) measures 38, all new functions are well under the threshold of 50.Non-move edits, each needed because a clang-tidy check that skips lambda bodies now applies to the moved code: 20 unnamed trailing
nlohmann::json&¶meters given a/*params*/name (readability-named-parameter); 5NOLINT(bugprone-unchecked-optional-access)added at pre-existing unchecked accesses now visible to the checker; 2 redundant trailingreturn;removed fromget_ready_app/get_ready_gov(readability-redundant-control-flow), matching the precedent infile_serving_handlers.h.Verified as a pure reshuffle by stripping comments/whitespace from each old lambda body and new function body and requiring exact equality after applying only the edits listed above; all handler bodies and the rest of
init_handlers()match.Tests: unit tests
frontend_testandnode_frontend_testpass; e2eschema_test,reconfiguration_test_suite, andnodes_testpass.Safety and compatibility
Pure reshuffle of existing code with no behaviour change: endpoint paths, verbs, adapters, auth policies, and registration order are unchanged, so there is no runtime, API, or compatibility impact.