Skip to content

refactor(client): cut cognitive complexity in narrow chat-panel orchestrator#1112

Open
NC1107 wants to merge 1 commit into
mainfrom
refactor/narrow-layout-cc-reduction
Open

refactor(client): cut cognitive complexity in narrow chat-panel orchestrator#1112
NC1107 wants to merge 1 commit into
mainfrom
refactor/narrow-layout-cc-reduction

Conversation

@NC1107
Copy link
Copy Markdown
Owner

@NC1107 NC1107 commented May 22, 2026

Summary

`_buildNarrowChatPanel` was a ~155-line method with nested GestureDetector callbacks, inline ternaries, and a duplicated lounge-shell early-return — SonarQube flagged it as one of the four remaining S3776 hotspots (CC≈25, budget=15). This PR splits it into seven small helpers; each is well under the budget, no behaviour change.

Behind the scenes

  • New helpers: `_buildLoungeShell`, `_buildNarrowChatContent`, `_selectConversationFromDrawer`, `_buildEdgeSwipeGestureWrapper`, `_handleSwipeStart`, `_handleSwipeUpdate`, `_handleSwipeEnd`, `_buildEdgeSwipePeek`.
  • Deduplicated the lounge-shell Scaffold — was repeated in both `_buildNarrowChatPanel` and `_buildNarrowLayout`.

Test plan

  • `flutter test test/widgets/` — 724/724 pass
  • `flutter analyze --fatal-infos` clean
  • `dart format` clean

References #1104.

…lpers

_buildNarrowChatPanel had cognitive complexity ~25 from inline GestureDetector
callbacks with nested ternaries and an inline lounge-shell early-return.

Extracted helpers:
  - _buildLoungeShell — reused at both narrow-layout entry points (was duplicated)
  - _buildNarrowChatContent — ChatPanel composition with the right callbacks
  - _selectConversationFromDrawer — the column-drawer pick-conversation closure
  - _buildEdgeSwipeGestureWrapper — wraps the gesture detector or returns child verbatim
  - _handleSwipeStart / _handleSwipeUpdate / _handleSwipeEnd — the 3 callbacks
  - _buildEdgeSwipePeek — the left-edge peek overlay

No behaviour change; all 724 widget tests still pass. Clears one of the four
S3776 hotspots flagged in the 2026-05-22 SonarQube baseline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant