Skip to content

refactor: remove dead code, duplication and high-complexity functions - #167

Merged
btouchard merged 2 commits into
mainfrom
refactor/codebase-cleanup
Oct 29, 2026
Merged

btouchard merged 2 commits into
mainfrom
refactor/codebase-cleanup

Conversation

@btouchard

Copy link
Copy Markdown
Member

Codebase cleanup driven by static analysis (deadcode, dupl, gocyclo). No behaviour change intended.

Dead code

  • Remove functions unreachable from main; test-only hooks move into test files, and tests of thin wrappers now target the real function.
  • Wire the Docker socket help message (SocketUnavailableError) into the connect paths, so an unreachable daemon tells the operator how to mount the socket or set DOCKER_HOST.

Duplication

  • store: one SQLite table rebuild helper, one row scanner interface, one paged listing helper, one retention purge logger.
  • kubernetes: shared controller event handler, workload ID, replica default, conditions and per-kind listing.
  • api: shared id, JSON and not-found handling in status page personalization.

Complexity (every function now under the gocyclo threshold)

  • app: main, New, Start and the alert callback wiring split into one step per subsystem.
  • alert: ChannelPatch shared by the REST and MCP channel updates.
  • multihost: one method per agent event kind; the Push session loop moves to its own type.

Two SQLite rebuild log lines are reworded (e.g. cert monitor SNI rebuild starting becomes cert sni rebuild starting).

- Delete functions unreachable from main; move test-only hooks into test
  files and point tests of thin wrappers at the real function.
- Show the Docker socket help message when the daemon does not answer.
- store: share the SQLite table rebuild, row scanning, paged listing and
  retention purge logging.
- kubernetes: share controller event handlers, workload IDs, replica
  defaults, conditions and the fields common to every controller kind.
- api: factor id, JSON decoding and not-found handling in status page
  personalization handlers.
- app: break main, New, Start and the alert callback wiring into one step
  per subsystem, with pure builders for alert events.
- alert: add ChannelPatch so the REST and MCP channel updates share the
  same field application and validation.
- multihost: route each agent event kind to its own method and move the
  Push session loop into a dedicated type.
- kubernetes: list every controller kind through one generic helper.
@btouchard
btouchard merged commit 9557d07 into main Oct 29, 2026
43 checks passed
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