src/core/tui/.clang-tidy raises readability-function-cognitive-complexity.Threshold to 210 for core::tui alone. The root .clang-tidy sets 50, and nothing outside core::tui is over it.
Before fix round 1 of Task A7 the check was simply off in that directory, with a comment saying "the number to watch is 18" — which nothing was watching, because a disabled check reports no count. The threshold replaces the disable so the number is measured again and a new offender is a build failure, but 210 is the largest function today, not a number anyone chose.
The functions over the root threshold, with their counts at the time of writing:
| Function |
Complexity |
InputField::render |
200 |
StyledText::fromMarkdown |
178 |
GenericSyntaxHighlighter's nine highlight*() lexers |
59–133 |
Screen::flushInline |
121 |
VtParser::dispatchCsi |
98 |
MarkdownRenderer::renderInline |
94 |
CompletionPopup::render |
62 |
MarkdownRenderer::renderTableCompact |
60 |
MarkdownTable::stripInlineMarkdown |
55 |
QuestionComponent::processInput |
53 |
Some of these are inherent: a hand-written lexer is a state machine over a character stream, and its branches are the language's tokens. Splitting one into named halves moves state into parameters without making it simpler to read. Others — the renderers, whose branches are the cases of the layout — probably can be paid down.
The work is to go through them one at a time, lower the threshold in src/core/tui/.clang-tidy as each drops, and delete the file's departure when the last one reaches 50. Each step is independent, so this can be done piecemeal.
Filed from Task A7 fix round 1, item 13. The comment in src/core/tui/.clang-tidy cites this issue.
src/core/tui/.clang-tidyraisesreadability-function-cognitive-complexity.Thresholdto 210 forcore::tuialone. The root.clang-tidysets 50, and nothing outsidecore::tuiis over it.Before fix round 1 of Task A7 the check was simply off in that directory, with a comment saying "the number to watch is 18" — which nothing was watching, because a disabled check reports no count. The threshold replaces the disable so the number is measured again and a new offender is a build failure, but 210 is the largest function today, not a number anyone chose.
The functions over the root threshold, with their counts at the time of writing:
InputField::renderStyledText::fromMarkdownGenericSyntaxHighlighter's ninehighlight*()lexersScreen::flushInlineVtParser::dispatchCsiMarkdownRenderer::renderInlineCompletionPopup::renderMarkdownRenderer::renderTableCompactMarkdownTable::stripInlineMarkdownQuestionComponent::processInputSome of these are inherent: a hand-written lexer is a state machine over a character stream, and its branches are the language's tokens. Splitting one into named halves moves state into parameters without making it simpler to read. Others — the renderers, whose branches are the cases of the layout — probably can be paid down.
The work is to go through them one at a time, lower the threshold in
src/core/tui/.clang-tidyas each drops, and delete the file's departure when the last one reaches 50. Each step is independent, so this can be done piecemeal.Filed from Task A7 fix round 1, item 13. The comment in
src/core/tui/.clang-tidycites this issue.