Skip to content

feat: implement issue #22 — SonarCloud: reduce cognitive complexity (S3776, CRITICAL) (×3) - #26

Closed
don-petry wants to merge 3 commits into
mainfrom
dev-lead/issue-22-20260703-2130
Closed

feat: implement issue #22 — SonarCloud: reduce cognitive complexity (S3776, CRITICAL) (×3)#26
don-petry wants to merge 3 commits into
mainfrom
dev-lead/issue-22-20260703-2130

Conversation

@don-petry

Copy link
Copy Markdown
Contributor

Closes #22

Implemented by dev-lead agent. Please review.

Copilot AI review requested due to automatic review settings July 3, 2026 21:39
@don-petry
don-petry requested a review from a team as a code owner July 3, 2026 21:39
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@don-petry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4122163-1916-4462-b6f0-dbe34fea2ad5

📥 Commits

Reviewing files that changed from the base of the PR and between 8eba91b and ce49842.

📒 Files selected for processing (5)
  • scripts/discover.py
  • scripts/extract_all.py
  • scripts/flatten.py
  • tests/conftest.py
  • tests/test_scripts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-22-20260703-2130

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the previously SonarCloud-flagged CLI script main() functions (S3776 cognitive complexity) by extracting smaller pure helpers, while adding unit tests to lock in helper behavior and adjusting pytest collection so unit tests always run without requiring a live API key.

Changes:

  • Extracted helper functions in scripts/discover.py, scripts/extract_all.py, and scripts/flatten.py to reduce cognitive complexity while preserving behavior.
  • Added new unit tests for extracted “pure” helpers (no network / no API key required).
  • Updated pytest collection behavior so only the live contract test module is skipped when BROODMINDER_API_KEY is not set.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_scripts.py Adds unit tests for extracted pure helpers (discover/flatten) to lock in behavior offline.
tests/conftest.py Changes skip logic so only live contract tests are skipped when no API key is present.
scripts/flatten.py Extracts metric discovery, row-building, per-hive flattening, and output writers to simplify main().
scripts/extract_all.py Extracts argument parsing, hive selection, per-window processing, and per-hive extraction loop helpers.
scripts/discover.py Extracts sample-id discovery and endpoint sampling into helpers to flatten main().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Remove unused `bm` parameter from `_sample_endpoint` (S1172) and replace
bare float equality assertions with `pytest.approx` (S1244).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) July 3, 2026 21:48
@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@don-petry
don-petry disabled auto-merge July 3, 2026 21:50
@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but it still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews), so I cannot mark it done yet. I'll re-check automatically.
Next attempt after: 2026-07-03T22:21:41Z

@don-petry
don-petry enabled auto-merge (squash) July 3, 2026 21:51
@don-petry
don-petry disabled auto-merge July 3, 2026 23:20
@don-petry
don-petry enabled auto-merge (squash) July 3, 2026 23:20
@don-petry
don-petry disabled auto-merge July 4, 2026 04:02
@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 04:04
@don-petry
don-petry disabled auto-merge July 4, 2026 07:17
@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 07:18
@don-petry
don-petry disabled auto-merge July 4, 2026 10:27
@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 10:29
@don-petry
don-petry disabled auto-merge July 4, 2026 15:21
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #26
No changes were committed, but the PR still has blocking checks or reviews (failing or cancelled checks, or changes-requested reviews). The retry cron will re-attempt automatically. Next attempt after: 2026-07-04T15:53:57Z

@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 15:24
@don-petry
don-petry disabled auto-merge July 4, 2026 17:18
@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 17:29
@don-petry
don-petry disabled auto-merge July 4, 2026 17:29
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead Fix CI — applied

PR: #26 | SHA: 766e37326b4f1858f77c86a90ee39e8c2b4b9498
Fix committed and pushed. Waiting for CI.

@don-petry
don-petry enabled auto-merge (squash) July 4, 2026 17:33
@don-petry
don-petry disabled auto-merge July 4, 2026 17:33
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry

Copy link
Copy Markdown
Contributor Author

Closing this conflicted (DIRTY) PR — main has evolved since it was generated (2026-07-03/07), so a hand-merge would drag stale code over main's newer version. Driving issue #22 keeps its dev-lead label, so this regenerates cleanly against current main (cap-gated, no work lost). (cognitive-complexity S3776; #34 dup already deduped)

@don-petry don-petry closed this Jul 15, 2026
auto-merge was automatically disabled July 15, 2026 02:37

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud: reduce cognitive complexity (S3776, CRITICAL) (×3)

3 participants