Skip to content

fix(lint): clear v2 violations in files skipped by other lint PRs#1332

Merged
cristim merged 1 commit into
mainfrom
fix/lint-gap-untouched-by-prs
Jul 3, 2026
Merged

fix(lint): clear v2 violations in files skipped by other lint PRs#1332
cristim merged 1 commit into
mainfrom
fix/lint-gap-untouched-by-prs

Conversation

@cristim

@cristim cristim commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Clears the ~45 golangci-lint v2 violations that PR #1276 deliberately skips because these 8 files are also touched by other open PRs (#1265, #1299, and feature branches). The internal/deploy/ package is excluded here since PR #1246 deletes it entirely.

Linters fixed per file:

File Linters
cmd/helpers_test.go govet (fieldalignment), unparam
cmd/main_test.go govet (fieldalignment)
cmd/multi_service_filters.go gocritic (hugeParam, rangeValCopy, equalFold), godot
cmd/multi_service_engine_versions_test.go govet (fieldalignment), godot
internal/auth/service_password_test.go govet (fieldalignment), godot
internal/auth/store_postgres_test.go govet (fieldalignment), godot
internal/purchase/approvals.go govet (shadow), misspell (cancelled->canceled, analogue->analog)
internal/purchase/messages.go gocritic (hugeParam, rangeValCopy), godot, misspell (authorised->authorized)

Incidental changes (required to fix callers of updated signatures):

  • cmd/multi_service{.go,_helpers.go,_test.go,_filters_test.go}: pass &cfg / &rec to updated filter functions
  • internal/purchase/{coverage_extra,money_path_regression}_test.go: pass &msg to updated handleExecutePurchase
  • internal/purchase/approvals_test.go, coverage_extra_test.go: update error-string assertions to match American spellings

Notable fixes:

  • multi_service_filters.go: all filter functions (applyFilters, shouldInclude*, processRecommendation, etc.) now take *Config and *common.Recommendation to avoid >360-byte copies per call; range loop fixed to use index-based iteration
  • messages.go: handleApproveMessage/handleCancelMessage/handleExecutePurchase take *AsyncMessage; gatherApproverContactEmails uses index-based range to avoid 312-byte copies
  • approvals.go: shadow fixed by renaming the inner err to checkErr in the preflight guard; all British-English variable names and error strings converted
  • cmd/main_test.go: positional struct literal order corrected after fieldalignment reordered fields (govet was failing)

Note: a rebase will be needed when #1265/#1276/#1299 merge, as those PRs touch overlapping files. That is expected and handled separately.

Test plan

  • go build ./... clean
  • go vet ./... clean
  • golangci-lint run ./cmd/... ./internal/auth/... ./internal/purchase/... shows 0 violations in the 8 target files
  • go test -race ./cmd/... -- 750 tests pass
  • go test -race ./internal/auth/... ./internal/purchase/... -- 760 tests pass

Summary by CodeRabbit

  • Bug Fixes

    • Improved filtering behavior across multi-service recommendations, including more reliable matching for engine include/exclude rules.
    • Updated purchase approval/cancellation flows to show clearer, consistent cancellation messaging.
  • Style

    • Standardized several user-facing messages and spelling, including American English wording in purchase-related notices.
  • Refactor

    • Improved internal handling of configuration and async purchase messages for more consistent processing.

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship urgency/eventually No deadline impact/internal Team-internal only effort/s Hours type/chore Maintenance / non-user-visible labels Jun 29, 2026
@cristim

cristim commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39d3dd05-1ae7-4b26-8623-3a8b7cbb264d

📥 Commits

Reviewing files that changed from the base of the PR and between cb115d2 and 74f5bd7.

📒 Files selected for processing (14)
  • cmd/helpers_test.go
  • cmd/main_test.go
  • cmd/multi_service.go
  • cmd/multi_service_engine_versions_test.go
  • cmd/multi_service_filters.go
  • cmd/multi_service_filters_test.go
  • cmd/multi_service_helpers.go
  • cmd/multi_service_test.go
  • internal/auth/service_password_test.go
  • internal/auth/store_postgres_test.go
  • internal/purchase/approvals.go
  • internal/purchase/coverage_extra_test.go
  • internal/purchase/messages.go
  • internal/purchase/money_path_regression_test.go
📝 Walkthrough

Walkthrough

Three independent sets of changes: filter pipeline functions in cmd/ converted from value to pointer parameters (*Config, *common.Recommendation) with strings.EqualFold for engine matching; async purchase message handlers in internal/purchase/ converted to *AsyncMessage with British-to-American spelling normalization ("cancelled"→"canceled", "authorised"→"authorized"); and cosmetic struct field reordering plus comment updates across multiple test files.

Changes

cmd/ Filter Pipeline Pointer Refactor

Layer / File(s) Summary
Filter function signatures: value → pointer
cmd/multi_service_filters.go
applyFilters, processRecommendation, passesDimensionFilters, shouldIncludePoolSize, shouldIncludeRegion, shouldIncludeInstanceType, shouldIncludeEngine, and shouldIncludeAccount all converted to accept *Config and/or *common.Recommendation; shouldIncludeEngine switches to strings.EqualFold.
Call sites updated to pass &cfg
cmd/multi_service.go, cmd/multi_service_helpers.go, cmd/multi_service_filters_test.go, cmd/multi_service_test.go
All invocations of applyFilters and shouldInclude* updated to pass &cfg / &toolCfg.

purchase: Pointer Params and Spelling Normalization

Layer / File(s) Summary
handleExecutePurchase/Approve/Cancel accept *AsyncMessage
internal/purchase/messages.go
ProcessMessage passes &msg; three handler methods now take *AsyncMessage; gatherApproverContactEmails uses index-based loop; "authorised" → "authorized".
CancelExecution spelling and log normalization
internal/purchase/approvals.go
ApproveExecution captures checkErr; CancelExecution and loadCancelableExecution error/log strings changed to "canceled".
Purchase tests updated
internal/purchase/approvals_test.go, internal/purchase/coverage_extra_test.go, internal/purchase/money_path_regression_test.go
Tests updated to pass &msg and expect "canceled"/"authorized" spellings.

Cosmetic Test and Doc Housekeeping

Layer / File(s) Summary
cmd/ test struct field reordering
cmd/helpers_test.go, cmd/main_test.go, cmd/multi_service_engine_versions_test.go
Table-driven test struct fields reordered; confirmPurchaseWithInput signature simplified to remove totalInstances/totalCost parameters.
internal/auth test reordering and comment updates
internal/auth/service_password_test.go, internal/auth/store_postgres_test.go
Struct field reordering in table-driven tests, MockRow.scanFunc moved before embedded mock.Mock, comment punctuation updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • LeanerCloud/CUDly#674: Modifies CancelExecution in internal/purchase/approvals.go to use CancelExecutionAtomic, the same function this PR touches for spelling normalization.
  • LeanerCloud/CUDly#1037: Modifies handleExecutePurchase and related async message handling in internal/purchase/messages.go, the same handlers this PR converts to pointer parameters.

Suggested labels

severity/low

🐇 A pointer here, a spelling there,
"Cancelled" hops to "canceled" with flair.
Struct fields reshuffled, tidy and neat,
&cfg passed through on every beat.
The rabbit tidies with utmost care! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main goal: fixing golangci-lint v2 violations in previously skipped files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lint-gap-untouched-by-prs

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

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.
@cristim cristim force-pushed the fix/lint-gap-untouched-by-prs branch from cb115d2 to 74f5bd7 Compare July 3, 2026 20:14
@cristim

cristim commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main (post-#1343).

Conflict resolution:

  • internal/purchase/approvals.go: took main's errors.Is(err, config.ErrNotFound) errcheck pattern as base; re-applied govet-shadow (err->checkErr for OrphanExecutionError) and misspell (analogue->analog). Dropped all cancelled->canceled respellings (identifiers cancelledBy/cancelled, log strings, error strings, comments) -- those belong to fix(db): rename status value cancelled->canceled (expand-contract, US spelling) #1277's expand-contract change and would collide on merge.
  • internal/purchase/approvals_test.go: reverted the two "cannot be canceled" test assertions back to "cannot be cancelled" to match the production string kept above.
  • internal/purchase/messages.go: no semantic conflict -- fix(ci): resolve main Build & Test failures - pgx CVE, errcheck wave, config test regressions #1343 changed ErrNotFound handling in a different function from what this branch touched (pointer params, godot, rangeValCopy, authorised->authorized). All lint fixes preserved cleanly.

12 non-conflicting files (cmd/*, internal/auth tests, internal/purchase test helpers): re-applied whole.

Gates passed:

  • go build ./...: exit 0
  • go vet ./...: exit 0
  • golangci-lint run --new-from-rev origin/main ./...: No issues found (0 new violations introduced)
  • go test ./cmd/... ./internal/auth/... ./internal/purchase/... -count=1: 1514 passed, exit 0

New HEAD: 74f5bd7

@cristim cristim merged commit bd9ad35 into main Jul 3, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/internal Team-internal only priority/p3 Polish / idea / may never ship triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant