Skip to content

Remove superseded and dead utility functions#195

Closed
gnanam1990 wants to merge 1 commit into
mainfrom
chore/remove-dead-code
Closed

Remove superseded and dead utility functions#195
gnanam1990 wants to merge 1 commit into
mainfrom
chore/remove-dead-code

Conversation

@gnanam1990

@gnanam1990 gnanam1990 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Behavior-preserving removal of dead utility code — functions unreachable from cmd/* and from the test suite (deadcode -test ./...), so deleting them changes no behavior.

Removed:

  • tools.CoreWriteTools / CoreShellTools — superseded by the …Scoped variants (the live registration path).
  • workspaceindex.MaxFileDepth — unused helper.
  • tui.indentText — unused string utility.
  • tuiTheme.onPanel2 + the now-orphaned colorPanel2 const — unused style helper.

Scope (deliberately narrow)

This is the safe-cleanup slice only — genuine cruft with no feature intent. The other ~18 truly-dead funcs are dormant/intended-but-unwired features (e.g. tui/composer.go line-editing, tui/mcp_view.go helpers, sessions.ReplayEvents, agenteval scoring). Those are wire-vs-delete decisions for their owners, not blind deletes, so they're intentionally left out.

Verification

  • go build ./..., go vet ./..., gofmt -l clean; full go test ./... green.
  • deadcode -test=false ./...: 114 → 109; truly-dead: 23 → 18.
  • sandbox/seccomp_other.go: ApplyUnixSocketBlock intentionally kept (non-Linux no-op stub).

Summary by CodeRabbit

  • Refactor
    • Internal code consolidation and cleanup to improve maintainability and reduce redundant utilities.

Behavior-preserving cleanup of functions unreachable even from tests:
- tools.CoreWriteTools / CoreShellTools — superseded by the …Scoped variants.
- workspaceindex.MaxFileDepth — unused helper.
- tui.indentText — unused string util.
- tuiTheme.onPanel2 + the now-orphaned colorPanel2 const — unused style helper.

deadcode -test=false: 114 -> 109; truly-dead: 23 -> 18. Scoped to genuine cruft only —
the remaining dead funcs are dormant/intended-but-unwired features (owner wire-vs-delete),
not blind deletes.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ff8372d2-3a9c-4ea0-93e6-70e63b1952be

📥 Commits

Reviewing files that changed from the base of the PR and between 0444eb0 and e018ee2.

📒 Files selected for processing (4)
  • internal/tools/registry.go
  • internal/tui/theme.go
  • internal/tui/view.go
  • internal/workspaceindex/workspaceindex.go
💤 Files with no reviewable changes (4)
  • internal/workspaceindex/workspaceindex.go
  • internal/tui/theme.go
  • internal/tui/view.go
  • internal/tools/registry.go

Walkthrough

Removes four dead-code identifiers — CoreWriteTools, CoreShellTools, MaxFileDepth, and the TUI colorPanel2/onPanel2 pair — and replaces the indentText helper in view.go with a looksLikeDiff detector that identifies diff-formatted output by hunk headers and file header markers.

Changes

Dead code removal across tools, TUI, and workspace index

Layer / File(s) Summary
Remove non-scoped tool registry wrappers
internal/tools/registry.go
CoreWriteTools and CoreShellTools are deleted; callers must use the scoped variants CoreWriteToolsScoped and CoreShellToolsScoped.
TUI theme token and view helper cleanup
internal/tui/theme.go, internal/tui/view.go
colorPanel2 constant and onPanel2 method removed from the theme; indentText removed from view helpers and replaced with looksLikeDiff, which returns a boolean by scanning for hunk headers and --- /+++ file markers.
Remove MaxFileDepth from workspace index
internal/workspaceindex/workspaceindex.go
Exported MaxFileDepth(files []File) int helper deleted; SortFiles now directly follows normalizeSeparators.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • Gitlawb/zero#159: Both PRs modify MaxFileDepth in internal/workspaceindex/workspaceindex.go — the prior PR adds it, this PR removes it.
  • Gitlawb/zero#48: Both PRs touch the CoreWriteTools/CoreShellTools entry points in internal/tools/registry.go — one adds them, this PR removes them.

Suggested reviewers

  • anandh8x
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing dead utility functions identified by static analysis, which aligns with the core objective throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-dead-code

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Zero automated PR review

Verdict: No blockers found

Blockers

  • None found.

Validation

  • [pass] Diff hygiene: git diff --check
  • [pass] Tests: go test ./...
  • [pass] Build: go run ./cmd/zero-release build
  • [pass] Smoke build: go run ./cmd/zero-release smoke

Scope

Head: e018ee27e0dd
Changed files (4): internal/tools/registry.go, internal/tui/theme.go, internal/tui/view.go, internal/workspaceindex/workspaceindex.go

This deterministic review checks validation status and basic diff hygiene. A human reviewer still owns product judgment and design quality.

@gnanam1990 gnanam1990 closed this Jun 14, 2026
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