refactor(recover): extract helper from recover_all to reduce complexity (S3776) #73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Claude/backup-script:fix/issue-3-S3776-recover-complexity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #3
recover_allhad cognitive complexity 21 (SonarQube ceiling: 15).Refactor
Extracted two single-purpose helpers from the per-marker body of the loop:
_read_trusted_compose_path(marker, *, log)— reads the marker, parsesthe compose-file path, resolves it strictly, and rejects symlinks /
non-canonical paths. Returns the resolved
PathorNone(with theunrecoverable marker already removed and the reason logged).
_start_stack_from_marker(marker, compose_path, *, log, timeout_per_stack_s)— invokes
docker compose start, unlinks the marker on success, logsstart/ok/failed. Returns
Trueiff the stack was restarted.The body of
recover_allcollapses to dir-walk + dispatch + counter.Behavior
Identical. All log keys, log levels, marker-unlink semantics, error
classes, and the return value (count of restarted stacks) are preserved
byte-for-byte. The two helpers are module-private (
_prefix) and notexported.
Verification
pytest -q tests/unit/— passesmypy --strict src/gardien/core src/gardien/config src/gardien/engine src/gardien/steps— passesView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.