From 7eece6de37c2b4e6a86299c676ff46f8913065f1 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Sat, 17 Oct 2026 19:20:36 +0200 Subject: [PATCH] lint: re-enable fieldalignment for production 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 --- .golangci.yml | 15 +++++++-------- cmd/archera_render.go | 4 ++-- cmd/main.go | 34 +++++++++++++++++----------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8f12e375a..0819b9791 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -59,12 +59,6 @@ linters: pattern: (?i)passwd|pass|password|pwd|secret|token govet: enable-all: true - disable: - # fieldalignment: many production structs have alignment violations that - # pre-date this PR; fixing them is a separate concern. Suppress globally - # rather than per-struct since golangci-lint v2.10.x (CI) doesn't treat - # severity:warning as a non-fatal exit, unlike v2.11+. - - fieldalignment misspell: locale: US revive: @@ -100,12 +94,17 @@ linters: # unusedwrite: test fixture struct fields may be set for documentation # completeness even when only a subset of fields is read by a given subtest. # Scoped to test files so production unusedwrite bugs remain visible. - # Note: fieldalignment is disabled globally in govet.disable (many - # pre-existing production violations; separate cleanup PR needed). - linters: - govet text: "unusedwrite" path: _test\.go + # fieldalignment: test-table memory layout is irrelevant, and reordering + # positional table literals risks silent misassignment. Production code + # stays checked. + - linters: + - govet + text: "fieldalignment:" + path: _test\.go - linters: - all path: .*_gen\.go diff --git a/cmd/archera_render.go b/cmd/archera_render.go index fd5849424..7aa093d3c 100644 --- a/cmd/archera_render.go +++ b/cmd/archera_render.go @@ -118,7 +118,7 @@ type archeraDeltaDTO struct { BreakevenDays *string `json:"breakeven_days"` } -type archeraOfferDTO struct { +type archeraOfferDTO struct { //nolint:govet // fieldalignment: field order is the JSON output contract (testdata/archera_json.golden) IsCurrent bool `json:"is_current"` OfferID string `json:"offer_id"` CommitmentType string `json:"commitment_type"` @@ -143,7 +143,7 @@ type archeraRowDTO struct { // archeraComparisonDTO is the CLI's stable JSON contract. Money values are // exact decimal strings; null means unknown, never zero. -type archeraComparisonDTO struct { +type archeraComparisonDTO struct { //nolint:govet // fieldalignment: field order is the JSON output contract (testdata/archera_json.golden) Title string `json:"title"` PlanID string `json:"plan_id"` FetchedAt string `json:"fetched_at"` diff --git a/cmd/main.go b/cmd/main.go index 636613e5b..740f2f77d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -40,14 +40,21 @@ type Config struct { // CallerAccountID is the account the credentials belong to (STS // GetCallerIdentity), set at run start. Purchases are refused for // recommendations owned by any other account. - CallerAccountID string - AuditLog string - CSVInput string - IdempotencyWindow string - ValidationProfile string - Profile string - PaymentOption string - CSVOutput string + CallerAccountID string + AuditLog string + CSVInput string + IdempotencyWindow string + ValidationProfile string + Profile string + PaymentOption string + CSVOutput string + SPAccountScope string + // RecLookbackPeriod controls the LookbackPeriodInDays passed to + // GetReservationPurchaseRecommendation. Valid values: "7d", "30d", "60d" + // (recommendations.DefaultRecLookbackPeriod is the shared default). + // A longer window smooths seasonal spikes; a shorter window weights + // recent demand more heavily. + RecLookbackPeriod string Regions []string Services []string ExcludeAccounts []string @@ -60,17 +67,16 @@ type Config struct { ExcludeEngines []string ExcludeSPTypes []string IncludeSPTypes []string - SPAccountScope string - MaxBreakEvenMonths int TargetCoverage float64 Coverage float64 MinPoolSize float64 + MinSavingsPct float64 + MaxBreakEvenMonths int RebuyWindowDays int TermYears int CoverageLookbackDays int MinCount int IdempotencyWindowHours int - MinSavingsPct float64 OverrideCount int32 MaxInstances int32 IncludeExtendedSupport bool @@ -82,12 +88,6 @@ type Config struct { // Count when no coverage was asked for (determineCSVCoverage). A Config // built in code leaves it false, so its Coverage is always honored. CoverageFromDefault bool - // RecLookbackPeriod controls the LookbackPeriodInDays passed to - // GetReservationPurchaseRecommendation. Valid values: "7d", "30d", "60d" - // (recommendations.DefaultRecLookbackPeriod is the shared default). - // A longer window smooths seasonal spikes; a shorter window weights - // recent demand more heavily. - RecLookbackPeriod string } func main() {