Skip to content

refactor(aws): reduce 4 offering-match funcs below gocyclo 10 (closes #1388)#1389

Merged
cristim merged 1 commit into
mainfrom
fix/gocyclo-aws-client-funcs
Jul 16, 2026
Merged

refactor(aws): reduce 4 offering-match funcs below gocyclo 10 (closes #1388)#1389
cristim merged 1 commit into
mainfrom
fix/gocyclo-aws-client-funcs

Conversation

@cristim

@cristim cristim commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Reduces cyclomatic complexity of 4 AWS service offering-match functions from 11 to 10, fixing the pre-commit gocyclo -over 10 hook that currently reddens CI on all-files runs.

Functions refactored (before -> after complexity)

Package Function Before After
providers/aws/services/redshift (*Client).findOfferingID 11 10
providers/aws/services/opensearch (*Client).findOfferingID 11 10
providers/aws/services/memorydb (*Client).findOfferingID 11 10
providers/aws/services/elasticache (*Client).paginateElastiCacheOfferings 11 10

Approach

Each package receives a new resolveTag(execID string) string helper that returns the execID when non-empty, or "no-exec" as a log-correlation sentinel. This replaces the inline if 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

  • All 212 existing tests in the 4 touched packages pass unchanged (zero test modifications).
  • gocyclo -over 10 providers/aws/services/ exits 0 with no violations.
  • go build ./... and go vet ./... exit 0 in both the providers/aws module and the root module.

Test plan

  • gocyclo -over 10 providers/aws/services/ -> 0 violations, exit 0
  • go build ./... in providers/aws -> exit 0
  • go vet ./... in providers/aws -> exit 0
  • go test ./services/redshift/... ./services/opensearch/... ./services/elasticache/... ./services/memorydb/... -> 212 passed, exit 0
  • go build ./... in root module -> exit 0
  • go vet ./... in root module -> exit 0

…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.
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-quarter Within the quarter impact/internal Team-internal only effort/s Hours type/chore Maintenance / non-user-visible labels Jul 16, 2026
@cristim

cristim commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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: 45 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: 674a7db0-ec49-4c23-b00c-2657b36b85a1

📥 Commits

Reviewing files that changed from the base of the PR and between 2448a02 and 7fe57c9.

📒 Files selected for processing (4)
  • providers/aws/services/elasticache/client.go
  • providers/aws/services/memorydb/client.go
  • providers/aws/services/opensearch/client.go
  • providers/aws/services/redshift/client.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gocyclo-aws-client-funcs

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

@coderabbitai

coderabbitai Bot commented Jul 16, 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.

@cristim
cristim merged commit 20dcff8 into main Jul 16, 2026
16 of 18 checks passed
@cristim
cristim deleted the fix/gocyclo-aws-client-funcs branch July 16, 2026 18:27
@cristim

cristim commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

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.

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/p2 Backlog-worthy severity/medium Moderate 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.

1 participant