Enable clang-tidy cognitive complexity checks#7995
Conversation
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Enables clang-tidy’s readability-function-cognitive-complexity check (previously disabled) with an initial higher threshold and macro-ignoring configuration, and establishes a baseline by adding targeted NOLINTNEXTLINE suppressions for existing over-threshold functions.
Changes:
- Enable
readability-function-cognitive-complexityand configure it withIgnoreMacros=trueandThreshold=50in.clang-tidy. - Add targeted
NOLINTNEXTLINE(readability-function-cognitive-complexity)annotations to known complex functions/tests to keep the new check actionable immediately.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.clang-tidy |
Enables and configures cognitive complexity checking with initial threshold + macro ignoring. |
src/node/test/historical_queries.cpp |
Suppresses existing over-threshold complexity in a TEST_CASE. |
src/node/rpc/node_frontend.h |
Suppresses existing over-threshold complexity in init_handlers(). |
src/node/rpc/frontend.h |
Suppresses existing over-threshold complexity in process_command_inner(). |
src/node/rpc/file_serving_handlers.h |
Suppresses existing over-threshold complexity in file-serving helper/initializer functions. |
src/node/node_state.h |
Suppresses existing over-threshold complexity in initiate_join_unsafe(). |
src/node/gov/handlers/service_state.h |
Suppresses existing over-threshold complexity in handler registration. |
src/node/gov/handlers/proposals.h |
Suppresses existing over-threshold complexity in handler registration. |
src/node/gov/handlers/acks.h |
Suppresses existing over-threshold complexity in handler registration. |
src/js/registry.cpp |
Suppresses existing over-threshold complexity in JS request execution path. |
src/indexing/test/indexing.cpp |
Suppresses existing over-threshold complexity in a multi-threaded indexing test. |
samples/apps/programmability/programmability.cpp |
Suppresses existing over-threshold complexity in constructor/handler setup. |
samples/apps/logging/logging.cpp |
Suppresses existing over-threshold complexity in init_handlers(). |
|
@copilot check you did not miss any functions? |
I ran clang-tidy with So no functions appear to have been missed for the files that could be fully analyzed in this environment. Any files that depend on system headers not present locally (e.g. |
|
@copilot what's failing in the latest CI then? |
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
CI was failing because |
readability-function-cognitive-complexitywas disabled, leaving highly complex functions invisible to clang-tidy. This enables the check with a higher initial threshold and macro expansion ignored.readability-function-cognitive-complexity.IgnoreMacros=trueto avoid logging/registration macro noise.Threshold=50as the initial enforcement level.NOLINTNEXTLINE(readability-function-cognitive-complexity)annotations for existing non-vendored functions currently above the threshold.