docs(refactoring): add TODO comments for high-complexity functions
Add TODO(#8) comments to document technical debt in 4 functions that exceed cyclomatic complexity thresholds: - splitNode (workspace_pane_ops.go) - complexity 65 - closePane (workspace_pane_ops.go) - complexity 31 - CloseStackedPane (stacked_panes.go) - complexity 49 - AttachKeyboardBridge (keyboard_bridge.go) - complexity 52 Issue #8 created to track future refactoring work. Note: All critical error handling issues identified in PR review were already fixed in earlier commits.
- commit
- 8008fcad50fb523aff3304ccf7a93c290cccab76
- author
- bnema · · 2025-10-24 17:51 UTC
- parent
- f19dc07
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
3 files · +8 -0
M internal/app/browser/stacked_panes.go +2 -0
| @@ -714,6 +714,8 @@ func (spm *StackedPaneManager) createTitleBarWithTitle(title string, pageURL str | |||
| 714 | 714 | return titleBox | |
| 715 | 715 | } | |
| 716 | 716 | ||
| 717 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (49 -> <30) | |
| 718 | + | // | |
| 717 | 719 | // CloseStackedPane handles closing a pane that is part of a stack. | |
| 718 | 720 | // The logic mirrors the regular close path: we rebuild the tree, update focus, | |
| 719 | 721 | // and let WorkspaceManager perform the actual cleanup/destroy work so that all | |
| @@ -714,6 +714,8 @@ func (spm *StackedPaneManager) createTitleBarWithTitle(title string, pageURL str | |||||
| 714 | return titleBox | 714 | return titleBox | ||
| 715 | } | 715 | } | ||
| 716 | 716 | ||||
| 717 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (49 -> <30) | |||
| 718 | + | // | |||
| 717 | // CloseStackedPane handles closing a pane that is part of a stack. | 719 | // CloseStackedPane handles closing a pane that is part of a stack. | ||
| 718 | // The logic mirrors the regular close path: we rebuild the tree, update focus, | 720 | // The logic mirrors the regular close path: we rebuild the tree, update focus, | ||
| 719 | // and let WorkspaceManager perform the actual cleanup/destroy work so that all | 721 | // and let WorkspaceManager perform the actual cleanup/destroy work so that all | ||
M internal/app/browser/workspace_pane_ops.go +4 -0
| @@ -299,6 +299,8 @@ func (wm *WorkspaceManager) removeFromAppPanes(pane *BrowserPane) { | |||
| 299 | 299 | // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption. | |
| 300 | 300 | // See splitNode() for the unified implementation. | |
| 301 | 301 | ||
| 302 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (65 -> <30) | |
| 303 | + | // | |
| 302 | 304 | // splitNode splits a target pane into two panes in the specified direction | |
| 303 | 305 | // splitNode splits a target pane into two panes in the specified direction. | |
| 304 | 306 | // If existingPane is provided, it will be used instead of creating a new WebView. | |
| @@ -922,6 +924,8 @@ func (wm *WorkspaceManager) setFocusToLeaf(node *paneNode) { | |||
| 922 | 924 | } | |
| 923 | 925 | } | |
| 924 | 926 | ||
| 927 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (31 -> <30) | |
| 928 | + | // | |
| 925 | 929 | // closePane closes a specific pane and handles tree restructuring (simplified implementation) | |
| 926 | 930 | func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) { | |
| 927 | 931 | ctx := wm.beginClose(node) | |
| @@ -299,6 +299,8 @@ func (wm *WorkspaceManager) removeFromAppPanes(pane *BrowserPane) { | |||||
| 299 | // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption. | 299 | // This eliminates widget reparenting of existing WebViews, which was causing rendering corruption. | ||
| 300 | // See splitNode() for the unified implementation. | 300 | // See splitNode() for the unified implementation. | ||
| 301 | 301 | ||||
| 302 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (65 -> <30) | |||
| 303 | + | // | |||
| 302 | // splitNode splits a target pane into two panes in the specified direction | 304 | // splitNode splits a target pane into two panes in the specified direction | ||
| 303 | // splitNode splits a target pane into two panes in the specified direction. | 305 | // splitNode splits a target pane into two panes in the specified direction. | ||
| 304 | // If existingPane is provided, it will be used instead of creating a new WebView. | 306 | // If existingPane is provided, it will be used instead of creating a new WebView. | ||
| @@ -922,6 +924,8 @@ func (wm *WorkspaceManager) setFocusToLeaf(node *paneNode) { | |||||
| 922 | } | 924 | } | ||
| 923 | } | 925 | } | ||
| 924 | 926 | ||||
| 927 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (31 -> <30) | |||
| 928 | + | // | |||
| 925 | // closePane closes a specific pane and handles tree restructuring (simplified implementation) | 929 | // closePane closes a specific pane and handles tree restructuring (simplified implementation) | ||
| 926 | func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) { | 930 | func (wm *WorkspaceManager) closePane(node *paneNode) (*paneNode, error) { | ||
| 927 | ctx := wm.beginClose(node) | 931 | ctx := wm.beginClose(node) | ||
M pkg/webkit/keyboard_bridge.go +2 -0
| @@ -94,6 +94,8 @@ var shortcutActions = map[string]string{ | |||
| 94 | 94 | altmod + "+" + keyArrowUp: directionUp, | |
| 95 | 95 | } | |
| 96 | 96 | ||
| 97 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (52 -> <30) | |
| 98 | + | // | |
| 97 | 99 | // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript | |
| 98 | 100 | // This is critical for allowing JavaScript KeyboardService to receive keyboard events | |
| 99 | 101 | // that would otherwise be consumed by GTK shortcuts | |
| @@ -94,6 +94,8 @@ var shortcutActions = map[string]string{ | |||||
| 94 | altmod + "+" + keyArrowUp: directionUp, | 94 | altmod + "+" + keyArrowUp: directionUp, | ||
| 95 | } | 95 | } | ||
| 96 | 96 | ||||
| 97 | + | // TODO(#8): Refactor this function to reduce cyclomatic complexity (52 -> <30) | |||
| 98 | + | // | |||
| 97 | // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript | 99 | // AttachKeyboardBridge attaches an EventControllerKey to bridge keyboard events to JavaScript | ||
| 98 | // This is critical for allowing JavaScript KeyboardService to receive keyboard events | 100 | // This is critical for allowing JavaScript KeyboardService to receive keyboard events | ||
| 99 | // that would otherwise be consumed by GTK shortcuts | 101 | // that would otherwise be consumed by GTK shortcuts | ||