Repository navigation
lint: re-enable fieldalignment for production code - #2262
Merged
Merged
Conversation
Remove fieldalignment from the govet disable list and reorder Config (cmd/main.go) to the optimal layout; field doc comments moved with their fields unchanged. All Config literals are keyed. archeraOfferDTO and archeraComparisonDTO carry //nolint:govet because their field order is the JSON output contract pinned by testdata/archera_json.golden; reordering would change CLI output. fieldalignment findings in _test.go files are excluded (matched by the "fieldalignment:" message text, so other govet checks still run in tests). Test-table memory layout is irrelevant, and reordering positional table literals risks silent misassignment. Closes #1373 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reached
This review includes 3 billable files and costs up to $0.75.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Or wait 5 minutes for your next included review. View limit details
Comment |
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.
Closes #1373
Summary
#1364 globally disabled govet's
fieldalignmentas deferred debt. This PR re-enables it for production code.Config(cmd/main.go): fields are reordered to satisfy the linter (strings, slices, float64, int, int32, bool). Each field keeps its doc comment, and everyConfigliteral in the repo is keyed.cmd/archera_render.go):archeraOfferDTOandarcheraComparisonDTOget//nolint:govet // fieldalignment: field order is the JSON output contract (testdata/archera_json.golden). Their field order is the JSON output order, so reordering them would change the output..golangci.yml:fieldalignmentis removed from the govet disable list, along with the stale note._test.goexclusion is added. It matches onlyfieldalignment:findings: test-table memory layout has no runtime effect, and reordering ~19 positional table literals risks silently misassigning values.shadow, still run in tests._rvcloop names: the issue suspected these were autofix leftovers. They are deliberate and avoid gocriticrangeValCopy(renaming them adds 9 lint issues), so they stay.Before this change: 40 findings. 3 were in production code, and only one,
archeraOfferDTO, was a real size change (248 to 240 bytes); the other 37 were in tests.Evidence (local, macOS,
GOTOOLCHAIN=go1.26.9)fieldalignmentenabled.Configfield fails lint (struct of size 552 could be 544).archeraOfferDTOnolint fails lint.archeraComparisonDTOfields failsTestArcheraComparisonJSON.shadowandunparamstill fire there.go test -race ./cmd/...passes (1610 tests), andcmd/testdatais unchanged.make build,go vet ./...andscripts/test-git-secrets-allowlist.sh(44/44) pass.🤖 Generated with Claude Code