Skip to content

Commit 83e1bb2

Browse files
committed
fix(lint): clear v2 violations in files skipped by other lint PRs
Fix the ~45 golangci-lint v2 violations that #1276 deliberately skips because these files are also touched by other open PRs (#1265, #1299). internal/deploy/* is excluded here as #1246 deletes that package. Files fixed and linters addressed: - cmd/helpers_test.go: fieldalignment (govet), unparam - cmd/main_test.go: fieldalignment (govet), also fix positional struct literals broken by field reordering - cmd/multi_service_filters.go: hugeParam + rangeValCopy (gocritic), equalFold (gocritic), godot; all filter functions updated to *Config / *Recommendation params with callers updated across the cmd package - cmd/multi_service_engine_versions_test.go: fieldalignment (govet), godot - internal/auth/service_password_test.go: fieldalignment (govet), godot - internal/auth/store_postgres_test.go: fieldalignment (govet), godot - internal/purchase/approvals.go: err-shadow (govet), misspell (analogue->analog, cancelled->canceled, cancelling->canceling) - internal/purchase/messages.go: hugeParam + rangeValCopy (gocritic), godot, misspell (authorised->authorized) Incidental changes: caller sites in cmd/multi_service{,_helpers,_test, _filters_test}.go; handle*Message signature callers in internal/purchase/{coverage_extra,money_path_regression}_test.go; test assertions updated to match renamed error strings.
1 parent 0973c67 commit 83e1bb2

8 files changed

Lines changed: 82 additions & 81 deletions

‎cmd/helpers_test.go‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ func TestApplyCountOverride(t *testing.T) {
199199
tests := []struct {
200200
name string
201201
recs []common.Recommendation
202-
overrideCount int32
203202
expectedCounts []int
203+
overrideCount int32
204204
}{
205205
{
206206
name: "Override with positive value",
@@ -252,8 +252,8 @@ func TestApplyCoverage(t *testing.T) {
252252
tests := []struct {
253253
name string
254254
recs []common.Recommendation
255-
coverage float64
256255
expectedCounts []int
256+
coverage float64
257257
expectedLen int
258258
}{
259259
{
@@ -383,8 +383,8 @@ func TestAdjustRecommendationsForExisting(t *testing.T) {
383383
name string
384384
inputRecs []common.Recommendation
385385
existingRIs []common.Commitment
386-
expectedLen int
387386
expectedCounts []int
387+
expectedLen int
388388
}{
389389
{
390390
name: "No existing RIs - all recommendations kept",
@@ -490,8 +490,8 @@ func TestAdjustRecommendationsForExisting(t *testing.T) {
490490
func TestGetRecommendationDescription(t *testing.T) {
491491
tests := []struct {
492492
name string
493-
rec common.Recommendation
494493
expected string
494+
rec common.Recommendation
495495
}{
496496
{
497497
name: "RDS recommendation with database details",
@@ -570,8 +570,8 @@ func TestNormalizeEngineName(t *testing.T) {
570570
func TestGetEngineFromRecommendation(t *testing.T) {
571571
tests := []struct {
572572
name string
573-
rec common.Recommendation
574573
expected string
574+
rec common.Recommendation
575575
}{
576576
{
577577
name: "DatabaseDetails value type",
@@ -627,7 +627,7 @@ func TestGetEngineFromRecommendation(t *testing.T) {
627627

628628
// confirmPurchaseWithInput is a testable variant of ConfirmPurchase that reads
629629
// from the provided reader rather than os.Stdin, allowing stdin to be mocked in tests.
630-
func confirmPurchaseWithInput(totalInstances int, totalCost float64, skipConfirmation bool, input string) bool {
630+
func confirmPurchaseWithInput(skipConfirmation bool, input string) bool {
631631
if skipConfirmation {
632632
return true
633633
}
@@ -693,7 +693,7 @@ func TestConfirmPurchaseInput(t *testing.T) {
693693

694694
for _, tt := range tests {
695695
t.Run(tt.name, func(t *testing.T) {
696-
result := confirmPurchaseWithInput(1, 10.0, false, tt.input)
696+
result := confirmPurchaseWithInput(false, tt.input)
697697
assert.Equal(t, tt.expected, result)
698698
})
699699
}
@@ -706,8 +706,8 @@ func TestAdjustRecommendationsForExistingRIsEdgeCases(t *testing.T) {
706706
name string
707707
inputRecs []common.Recommendation
708708
existingRIs []common.Commitment
709-
expectedLen int
710709
expectedCounts []int
710+
expectedLen int
711711
}{
712712
{
713713
name: "Multiple RIs same instance type different regions",
@@ -771,9 +771,9 @@ func TestApplyInstanceLimit(t *testing.T) {
771771
tests := []struct {
772772
name string
773773
recs []common.Recommendation
774-
maxInstances int32
775-
expectedLen int
776774
expectedCounts []int
775+
expectedLen int
776+
maxInstances int32
777777
}{
778778
{
779779
name: "No limit - all recommendations kept",

‎cmd/main_test.go‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ func TestGetAllServices(t *testing.T) {
9898
func TestGeneratePurchaseID(t *testing.T) {
9999
tests := []struct {
100100
name string
101-
rec common.Recommendation
102101
region string
102+
expectedPrefix string
103+
rec common.Recommendation
103104
index int
104-
isDryRun bool
105105
coverage float64
106-
expectedPrefix string
106+
isDryRun bool
107107
}{
108108
{
109109
name: "RDS Recommendation - dry run",
@@ -401,11 +401,11 @@ func TestGeneratePurchaseIDComprehensive(t *testing.T) {
401401

402402
tests := []struct {
403403
name string
404-
rec common.Recommendation
405404
region string
406-
isDryRun bool
405+
rec common.Recommendation
407406
expectedContains []string
408407
expectedNotContains []string
408+
isDryRun bool
409409
}{
410410
{
411411
name: "RDS with account name and engine",
@@ -617,15 +617,15 @@ func TestGeneratePurchaseIDCoverageVariations(t *testing.T) {
617617

618618
tests := []struct {
619619
name string
620-
coverage float64
621620
expectedCoverage string
621+
coverage float64
622622
}{
623-
{"Coverage 0%", 0.0, "0pct"},
624-
{"Coverage 50%", 50.0, "50pct"},
625-
{"Coverage 75.5%", 75.5, "76pct"}, // Rounds to nearest integer
626-
{"Coverage 99%", 99.0, "99pct"},
627-
{"Coverage 100%", 100.0, "100pct"},
628-
{"Coverage 33.3%", 33.3, "33pct"},
623+
{"Coverage 0%", "0pct", 0.0},
624+
{"Coverage 50%", "50pct", 50.0},
625+
{"Coverage 75.5%", "76pct", 75.5}, // Rounds to nearest integer
626+
{"Coverage 99%", "99pct", 99.0},
627+
{"Coverage 100%", "100pct", 100.0},
628+
{"Coverage 33.3%", "33pct", 33.3},
629629
}
630630

631631
for _, tt := range tests {
@@ -685,12 +685,12 @@ func TestFilterFlagValidation(t *testing.T) {
685685

686686
tests := []struct {
687687
name string
688+
errorContains string
688689
includeRegions []string
689690
excludeRegions []string
690691
includeInstanceTypes []string
691692
excludeInstanceTypes []string
692693
expectError bool
693-
errorContains string
694694
}{
695695
{
696696
name: "No conflicts",
@@ -770,9 +770,9 @@ func TestCreateServiceClientAllServices(t *testing.T) {
770770
func TestValidateFlags(t *testing.T) {
771771
tests := []struct {
772772
name string
773+
setPayment string
773774
setCoverage float64
774775
setTerm int
775-
setPayment string
776776
expectError bool
777777
}{
778778
{
@@ -846,21 +846,21 @@ func TestValidateFlagsExtended(t *testing.T) {
846846
}()
847847

848848
tests := []struct {
849-
name string
850-
setCoverage float64
851-
setTerm int
852-
setPayment string
853-
setMaxInstances int32
854-
setCSVOutput string
855849
setCSVInput string
850+
setCSVOutput string
851+
errorContains string
852+
setPayment string
853+
name string
856854
setIncludeEngines []string
857-
setExcludeEngines []string
858-
setIncludeAccounts []string
859855
setExcludeAccounts []string
856+
setIncludeAccounts []string
857+
setExcludeEngines []string
860858
setIncludeTypes []string
861859
setExcludeTypes []string
860+
setCoverage float64
861+
setTerm int
862+
setMaxInstances int32
862863
expectError bool
863-
errorContains string
864864
}{
865865
// Coverage boundary tests
866866
{
@@ -1104,8 +1104,8 @@ func TestSanitizeAccountName(t *testing.T) {
11041104
func TestGeneratePurchaseID_EdgeCases(t *testing.T) {
11051105
tests := []struct {
11061106
name string
1107-
rec common.Recommendation
11081107
region string
1108+
rec common.Recommendation
11091109
index int
11101110
isDryRun bool
11111111
}{
@@ -1179,9 +1179,9 @@ func TestGeneratePurchaseID_EdgeCases(t *testing.T) {
11791179
func TestValidateInstanceTypes(t *testing.T) {
11801180
tests := []struct {
11811181
name string
1182+
errorContains string
11821183
instanceTypes []string
11831184
expectError bool
1184-
errorContains string
11851185
}{
11861186
{
11871187
name: "Empty slice is valid",

‎cmd/multi_service.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func filterAndAdjustRecommendations(recommendations []common.Recommendation, csv
394394

395395
// Apply filters (empty currentRegion since we're processing from CSV, not iterating regions)
396396
originalCount := len(recommendations)
397-
recommendations = applyFilters(recommendations, cfg, instanceVersions, versionInfo, "")
397+
recommendations = applyFilters(recommendations, &cfg, instanceVersions, versionInfo, "")
398398
if len(recommendations) < originalCount {
399399
AppLogger.Printf("🔍 After filters: %d recommendations (filtered out %d)\n", len(recommendations), originalCount-len(recommendations))
400400
}

‎cmd/multi_service_engine_versions_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111

1212
func TestAdjustRecommendationForExcludedVersions(t *testing.T) {
1313
tests := []struct {
14-
name string
15-
recommendation common.Recommendation
1614
versionInfo map[string]MajorEngineVersionInfo
1715
instanceVersions map[string][]InstanceEngineVersion
16+
name string
17+
recommendation common.Recommendation
1818
expectedCount int
1919
expectedAdjusted bool
2020
}{
@@ -313,7 +313,7 @@ func TestExtractMajorVersion_Additional(t *testing.T) {
313313
}
314314
}
315315

316-
// Comprehensive tests for extractMajorVersion function
316+
// Comprehensive tests for extractMajorVersion function.
317317
func TestExtractMajorVersion_Comprehensive(t *testing.T) {
318318
tests := []struct {
319319
name string
@@ -502,10 +502,10 @@ func TestIsInExtendedSupport(t *testing.T) {
502502
futureDate := now.AddDate(3, 0, 0)
503503

504504
tests := []struct {
505+
versionInfo map[string]MajorEngineVersionInfo
505506
name string
506507
engine string
507508
version string
508-
versionInfo map[string]MajorEngineVersionInfo
509509
expected bool
510510
}{
511511
{

0 commit comments

Comments
 (0)