refactor(planner): extract helpers from plan() to reduce complexity (S3776) #76

Open
Claude wants to merge 1 commit from Claude/backup-script:fix/issue-26-S3776-planner-complexity into master
First-time contributor

Closes #26

Planner.plan had cognitive complexity 16 (SonarQube ceiling: 15).

Refactor

Pulled the first two preamble sections out of plan() into named helpers:

  • _discover_compose_couplings() — runs compose_disco.discover (when
    enabled) and returns (compose_result, coupled_www_paths) so the caller no
    longer needs to track the None case + a separate for stack in compose_result.stacks loop.
  • _add_etckeeper_preflight(plan) — owns the etc.enabled /
    etckeeper_installed / commit / push ladder that produced the deepest
    nesting in plan(). Early-returns instead of nesting.

plan() now reads top-to-bottom as four numbered steps and contains a single
loop (the destination x category walk). Same Plan output, same log event,
same step ordering.

Behavior

Identical.

Verification

  • pytest -q tests/unit/ — passes (golden planner tests included)
  • mypy --strict src/gardien/core src/gardien/config src/gardien/engine src/gardien/steps — passes
Closes #26 `Planner.plan` had cognitive complexity 16 (SonarQube ceiling: 15). ### Refactor Pulled the first two preamble sections out of `plan()` into named helpers: - `_discover_compose_couplings()` — runs `compose_disco.discover` (when enabled) and returns `(compose_result, coupled_www_paths)` so the caller no longer needs to track the `None` case + a separate `for stack in compose_result.stacks` loop. - `_add_etckeeper_preflight(plan)` — owns the `etc.enabled` / `etckeeper_installed` / `commit` / `push` ladder that produced the deepest nesting in `plan()`. Early-returns instead of nesting. `plan()` now reads top-to-bottom as four numbered steps and contains a single loop (the destination x category walk). Same Plan output, same log event, same step ordering. ### Behavior Identical. ### Verification - `pytest -q tests/unit/` — passes (golden planner tests included) - `mypy --strict src/gardien/core src/gardien/config src/gardien/engine src/gardien/steps` — passes
`Planner.plan` had cognitive complexity 16 (SonarQube ceiling: 15).
Extract `_discover_compose_couplings` and `_add_etckeeper_preflight`.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix/issue-26-S3776-planner-complexity:Claude-fix/issue-26-S3776-planner-complexity
git switch Claude-fix/issue-26-S3776-planner-complexity

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff Claude-fix/issue-26-S3776-planner-complexity
git switch Claude-fix/issue-26-S3776-planner-complexity
git rebase master
git switch master
git merge --ff-only Claude-fix/issue-26-S3776-planner-complexity
git switch Claude-fix/issue-26-S3776-planner-complexity
git rebase master
git switch master
git merge --no-ff Claude-fix/issue-26-S3776-planner-complexity
git switch master
git merge --squash Claude-fix/issue-26-S3776-planner-complexity
git switch master
git merge --ff-only Claude-fix/issue-26-S3776-planner-complexity
git switch master
git merge Claude-fix/issue-26-S3776-planner-complexity
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bc1bb/backup-script!76
No description provided.