refactor(aws): reduce 4 offering-match funcs below gocyclo 10 (closes #1388)#1389
Conversation
…1388) Extract resolveTag(execID string) string into each of the four AWS service packages (redshift, opensearch, elasticache, memorydb) and replace the inline `if tag == ""` branch inside findOfferingID / paginateElastiCacheOfferings. This removes one cyclomatic-complexity unit from each function, dropping all four from 11 to 10 so the pre-commit `gocyclo -over 10` hook passes on all-files runs without changing any control-flow semantics or return values.
|
@coderabbitai review |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Action performedReview finished.
|
|
Merged to main (closes #1388): the 4 offering-match functions (redshift/opensearch/memorydb findOfferingID, elasticache paginateElastiCacheOfferings) are refactored from gocyclo complexity 11 to 10 via a shared resolveTag helper, no behavior change, tests unchanged. These crossed the pre-commit/Lint gocyclo -over 10 threshold when #1207 added fail-loud term handling (they stayed under golangci's 15, so review missed it). This greens the gocyclo step in BOTH the pre-commit and Lint Code jobs repo-wide, unblocking every open PR's pre-commit. Verified: gocyclo -over 10 exit 0, 212 service tests pass unchanged, pre-commit job green on this PR. |
Summary
Reduces cyclomatic complexity of 4 AWS service offering-match functions from 11 to 10, fixing the pre-commit
gocyclo -over 10hook that currently reddens CI on all-files runs.Functions refactored (before -> after complexity)
providers/aws/services/redshift(*Client).findOfferingIDproviders/aws/services/opensearch(*Client).findOfferingIDproviders/aws/services/memorydb(*Client).findOfferingIDproviders/aws/services/elasticache(*Client).paginateElastiCacheOfferingsApproach
Each package receives a new
resolveTag(execID string) stringhelper that returns the execID when non-empty, or"no-exec"as a log-correlation sentinel. This replaces the inlineif tag == ""branch in each function, removing exactly one complexity unit per function.No control-flow semantics, error handling, or return values were changed.
No-behavior-change assurance
gocyclo -over 10 providers/aws/services/exits 0 with no violations.go build ./...andgo vet ./...exit 0 in both the providers/aws module and the root module.Test plan
gocyclo -over 10 providers/aws/services/-> 0 violations, exit 0go build ./...in providers/aws -> exit 0go vet ./...in providers/aws -> exit 0go test ./services/redshift/... ./services/opensearch/... ./services/elasticache/... ./services/memorydb/...-> 212 passed, exit 0go build ./...in root module -> exit 0go vet ./...in root module -> exit 0