Skip to content

refactor: Reconcile method has excessive cyclomatic complexity (~40+) #39

Description

@digiserg

Summary

AxonOpsServerReconciler.Reconcile is 376 lines with deep nesting, multiple conditional branches, and a // nolint:gocyclo suppression. It handles finalizers, cert-manager verification, TimeSeries/Search/Server/Dashboard reconciliation (each with 3+ branches), and status updates all in one method.

Detailed Requirements

The Reconcile method should be an orchestrator of approximately 20 lines that delegates to component-specific methods. Each component (TimeSeries, Search, Server, Dashboard) should have its own reconciliation entry point method. Finalizer handling, cert-manager checks, and status updates should be extracted into their own methods.

The nolint:gocyclo suppression must be removed after refactoring.

Location

  • internal/controller/axonopsserver_controller.go:236-612

Acceptance Criteria

  1. Reconcile method is under 50 lines, delegating to component-specific methods
  2. Each component (TimeSeries, Search, Server, Dashboard) has its own reconciliation entry point
  3. nolint:gocyclo suppression is removed
  4. All existing tests continue to pass without modification
  5. No behavioral changes — pure refactoring

Testing Requirements

  • All existing unit tests must pass unchanged
  • Run golangci-lint with gocyclo enabled (no nolint) and verify no violations
  • Each extracted method should be independently testable

Documentation Requirements

  • Add godoc comments to each extracted method explaining its responsibility

Dependencies

  • None (but this refactoring makes other fixes easier to implement)

Priority

BLOCKING — maintainability risk; high cyclomatic complexity makes other bug fixes risky

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt and code quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions