Skip to content

refactor: extract sync uninstall and chart lock helpers - #2898

Merged
yxxhero merged 1 commit into
helmfile:mainfrom
ViktorBystrov72:refactor/release-helper-complexity
Nov 15, 2026
Merged

yxxhero merged 1 commit into
helmfile:mainfrom
ViktorBystrov72:refactor/release-helper-complexity

Conversation

@ViktorBystrov72

Copy link
Copy Markdown
Contributor

Extract the undesired-release uninstall lifecycle and the chart-lock repository matching loop into named helpers, restoring the gocognit limit to 110. Hook order, mutex boundaries, error bookkeeping, Name+Alias matching, normalization and digest handling retain their existing behavior.

Fixes #2850.

Measured with golangci-lint 2.15.0:

Function Before After
SyncReleases 112 99
rewriteChartDependencies 115 98

The extracted helpers score 7 and 9. The existing undesired-release failure test now also covers failing pre/post-uninstall hooks and verifies whether Helm deletion occurred.

Validation on Go 1.27.3:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the state-management helper refactor.

No open issues 🎉

What changed in this PR

This PR reduces complexity in Helmfile’s state-management code by extracting two helpers, addressing #2850 while preserving uninstall behavior and chart-lock handling.

Changes:

  • Extracts undesired-release uninstallation and chart-lock repository matching into named helpers.
  • Extends uninstall-failure tests to cover pre/post-uninstall hook failures and verify whether Helm deletion occurred.
  • Restores the cognitive-complexity limit from 120 to 110.
File Description
pkg/​state/​state.go Extracts helpers while preserving hook order, locking, error bookkeeping, and dependency matching.
pkg/​state/​state_test.go Adds uninstall-hook failure cases and deletion-count assertions.
.golangci.yaml Restores the cognitive-complexity limit to 110.

Review effort: Balanced

@yxxhero
yxxhero merged commit 5345697 into helmfile:main Nov 15, 2026
17 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.

Reduce cognitive complexity of SyncReleases and rewriteChartDependencies below 110

3 participants