Skip to content

lint: re-enable fieldalignment for production code - #2262

Merged
cristim merged 1 commit into
mainfrom
lint/fieldalignment-cleanup
Oct 17, 2026
Merged

cristim merged 1 commit into
mainfrom
lint/fieldalignment-cleanup

Conversation

@cristim

@cristim cristim commented Oct 17, 2026

Copy link
Copy Markdown
Member

Closes #1373

Summary

#1364 globally disabled govet's fieldalignment as 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 every Config literal in the repo is keyed.
  • Archera DTOs (cmd/archera_render.go): archeraOfferDTO and archeraComparisonDTO get //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:
    • fieldalignment is removed from the govet disable list, along with the stale note.
    • A _test.go exclusion is added. It matches only fieldalignment: findings: test-table memory layout has no runtime effect, and reordering ~19 positional table literals risks silently misassigning values.
    • Other govet checks, such as shadow, still run in tests.
  • _rvc loop names: the issue suspected these were autofix leftovers. They are deliberate and avoid gocritic rangeValCopy (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)

  • golangci-lint v2.10.1 (the CI pin) reports 0 issues with fieldalignment enabled.
  • Mutation probes:
    • A misaligned Config field fails lint (struct of size 552 could be 544).
    • Removing the archeraOfferDTO nolint fails lint.
    • Swapping two archeraComparisonDTO fields fails TestArcheraComparisonJSON.
    • A misaligned struct in a test file is ignored, while shadow and unparam still fire there.
  • go test -race ./cmd/... passes (1610 tests), and cmd/testdata is unchanged.
  • make build, go vet ./... and scripts/test-git-secrets-allowlist.sh (44/44) pass.
  • Review: two passes by an independent non-author reviewer (sonnet, high) found no actionable findings at 7eece6d. The reviewer judged the test exclusion acceptable against the issue's "no masking" origin, because production code is now checked.

🤖 Generated with Claude Code

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>
@cristim cristim added priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-quarter Within the quarter impact/internal Team-internal only effort/m Days type/chore Maintenance / non-user-visible triaged Item has been triaged labels Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 75 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 1477a3da-2eae-41e7-b0ba-71097ca442e3
📥 Commits

Reviewing files that changed from the base of the PR and between 0f7b9b6 and 7eece6d.

📒 Files selected for processing: 3
  • .golangci.yml
  • cmd/archera_render.go
  • cmd/main.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cristim
cristim merged commit 295cd13 into main Oct 17, 2026
12 checks passed
@cristim
cristim deleted the lint/fieldalignment-cleanup branch October 18, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint: complete fieldalignment cleanup and re-enable the linter (deferred in #1364) [cli part]

1 participant