Repository navigation
refactor: tidy source, tests and docs - #178
Draft
yesdevnull wants to merge 1 commit into
Draft
yesdevnull wants to merge 1 commit into
yesdevnull wants to merge 1 commit into
Conversation
Condense doc comments to idiomatic Go, replacing the parameter and return tables with one-paragraph summaries, and trim the longest explanatory comments while keeping the reasoning they record. Source simplifications, with no change to CLI output or exit codes: - share the dry-run prefix/verb through updateVerb and the module skip warning through moduleUpdateOptions.warnSkip - drop the always-equal changed result from the module and provider block updaters, and the explicit zeroing of named results - replace containsVersion with slices.Contains and the three-helper wildcard matcher with one function that searches the middle parts between the fixed prefix and suffix - share the object item byte-range check between the updater and the audit through objectItemValueRange - record report block IDs into caller-owned maps rather than returning them, and fill configOutcome directly in runConfigFileMode - wrap nested errors with %w, and switch FromVersions.UnmarshalYAML to a kind switch with errors.Is for EOF Disable staticcheck ST1005 in .golangci.yml, since the CLI prints its capitalised Error strings verbatim, and remove the per-line nolint directives it needed. Tests: build runMainCommand, captureRunnerOutput, captureStream, captureLog and captureStdoutAndStderr on two shared redirectStream and redirectLog primitives; move the updateTerraformVersion adapter beside the other test-only adapters; skip the read-only release-pin test as root like the other permission tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K3nZPPpASKdKUe8n5vqdoe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A code quality and cleanup pass over the tool, with a secondary pass over the tests and the agent docs. CLI output, flags, exit codes and the JSON contracts are unchanged.
Source (
main.go,config.go,audit.go)updateVerbsupplies the✓ Updated/→ Would updateprefix and verb that three loops each built by hand;moduleUpdateOptions.warnSkipprints the three module skip warnings that each spelt out the sameFprintf.changedresult that always equalledupdated;updateProviderBlockSyntaxResultreturns only the changed indexes.containsVersionis replaced byslices.Contains,shouldIgnoreModuleusesslices.ContainsFunc, and the three-helper wildcard matcher becomes onematchPatternthat searches the middle parts between the fixed prefix and suffix (same semantics, samepattern_test.go).objectItemValueRangeis shared by the updater and the audit instead of two copies of the byte-range check;replaceProviderObjectVersionusesslices.Cloneandslices.Concat.updateReportrecords block IDs into caller-owned maps rather than returning them;runConfigFileModefillsconfigOutcomedirectly andprintConfigSummaryprints its count lines through one helper.%w;FromVersions.UnmarshalYAMLis a kind switch andloadConfiguseserrors.Isfor EOF..golangci.ymldisables staticcheck ST1005 (the CLI prints its capitalisedError:strings verbatim), which removes the ~25 per-line//nolint:staticcheckdirectives.Tests
runMainCommand,captureRunnerOutput,captureStream,captureLogandcaptureStdoutAndStderrare rebuilt on two shared primitives,redirectStreamandredirectLog, replacing five hand-rolled pipe/drain/restore sequences.updateTerraformVersionadapter moves beside the other adapters intest_helpers_test.go.TestUpdateActionsReleasePinRejectsUnwritableTargetWithoutPartialChangesnow skips as root like the other permission tests (it failed when run as root).Docs
CLAUDE.md: the "Errors and output" and-report-fileparagraphs are condensed, and the lint section notes the ST1005 change.Validation
go vet,go test -race -coverprofile=...(coverage 94.3%),golangci-lint runon v2.12.2 (0 issues),go build,make actionlint, and a manual dry run and real run of the built binary overexamples/*.tfin a scratch directory.make shellcheckwas not run here (shellcheck is not installed in this environment); no shell scripts changed.Generated by Claude Code