Skip to content

refactor: Stage 1 strangler-fig -- extract mcp_integrator.py::install #1004

@sergio-sisternes-epam

Description

@sergio-sisternes-epam

Context

PR #999 introduced Ruff code quality guardrails with complexity thresholds set just above current codebase maximums (strangler-fig pattern). This is the first tightening stage.

Problem

src/apm_cli/integration/mcp_integrator.py::install is the single worst complexity outlier, owning three metrics simultaneously:

Metric Current value Stage 1 target Final target
max-statements 282 200 50
max-complexity (McCabe) 104 80 30
max-branches 125 90 25

Refactoring this one method unlocks threshold reductions across all three metrics for the entire codebase.

Suggested approach

  1. Extract distinct phases of the install method into private helper methods (e.g., _validate_inputs, _resolve_dependencies, _deploy_files, _run_hooks)
  2. Each extracted method should be under 50 statements
  3. After extraction, update the thresholds in pyproject.toml to the Stage 1 values
  4. Run uv run ruff check src/ tests/ to confirm no new violations

Files to touch

  • src/apm_cli/integration/mcp_integrator.py -- refactor install
  • pyproject.toml -- tighten max-statements, max-complexity, max-branches

Full strangler-fig roadmap

From the simulation in #999:

Stage max-stmts max-complexity max-branches Files to fix
Current 300 110 130 0
Stage 1 200 80 90 8
Stage 2 100 40 50 34
Stage 3 75 25 30 58
Target 50 15 25 79

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCLI command surface, flags, help text (cross-cutting).good first issueGood for newcomerspriority/lowAccepted but not time-sensitivestatus/acceptedDirection approved, safe to start work.status/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).tech-debttype/refactorInternal restructure, no behavior change.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions