Skip to content

feat: implement issue #168 — SonarCloud: cognitive complexity (S3776) - #173

Closed
don-petry wants to merge 11 commits into
mainfrom
dev-lead/issue-168-20261013-2154
Closed

don-petry wants to merge 11 commits into
mainfrom
dev-lead/issue-168-20261013-2154

Conversation

@don-petry

@don-petry don-petry commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

SonarCloud: cognitive complexity (S3776)

From the issue: 14 open SonarCloud finding(s) in petry-projects/incubator, worst severity CRITICAL. Generated by the org SonarCloud Audit.

Risk

Low — 8 file(s) changed; no CI- or runtime-critical paths touched.

Test plan

No test files were added or updated. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the existing CI (bats + lint) guards the change.

Rollback

Revert this PR. No non-revertible side effects (no tags, migrations, or external state).

Monitoring

This PR's CI checks (Lint + bats) are the success/regression signal.

Closes #168

View guided diff Turn on auto-fix

@don-petry
don-petry requested a review from a team as a code owner October 13, 2026 21:59
@don-petry don-petry added the auto-rebase:ready Opts a non-draft PR into auto-rebase without an approval (auto-rebase ready_label) label Oct 13, 2026
@coderabbitai

This comment has been minimized.

@don-petry

Copy link
Copy Markdown
Contributor Author

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

PR: #173
No changes were committed, but the PR still can't be marked done: required check SonarCloud is still pending. The retry cron will re-attempt automatically. Next attempt after: 2026-10-13T22:30:43Z

@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but I can't mark it done yet: required check SonarCloud is still pending. I'll re-check automatically.
Next attempt after: 2026-10-13T22:30:43Z

@don-petry
don-petry enabled auto-merge (squash) October 13, 2026 22:00

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request performs a comprehensive refactoring of the demand-radar codebase, modularizing several scripts by extracting monolithic logic into smaller, focused helper functions. These changes improve readability and maintainability across data processing, dashboard exporting, and review analysis scripts. Feedback suggests replacing Object.hasOwn in the dashboard template with a simpler logical OR fallback to prevent potential compatibility issues in older browsers or WebViews.

Comment thread pocs/demand-radar/dashboard.tmpl.html Resolved
@chatgpt-codex-connector

This comment has been minimized.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-13T23:03:00Z.

@don-petry
don-petry disabled auto-merge October 13, 2026 22:03
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed. Requested items addressed:

  • pocs/demand-radar/dashboard.tmpl.html:336 — applied

@don-petry
don-petry enabled auto-merge (squash) October 13, 2026 22:03
Comment thread pocs/demand-radar/deep_dive.py Resolved
@codeant-ai

codeant-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

2 code suggestions

1. When Reddit's token request fails, this call propagates the raw exception; run_cli only handles StageError, so the CLI exits with a traceback instead of a stage error.

Api mismatch · pocs/demand-radar/enrich_community.py:303


2. When the 10th processed leader has a note, this skips the checkpoint, so a crash before the final write loses earlier successful scans.

Logic error · pocs/demand-radar/resented_giants.py:250

@codeant-ai

This comment has been minimized.

@don-petry
don-petry disabled auto-merge October 13, 2026 22:05
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-13T23:05:40Z.

@don-petry

Copy link
Copy Markdown
Contributor Author

The PR's Quality Gate has passed with all measures showing acceptable status: 0 Security Hotspots, 99.7% Coverage on New Code, and 0.0% Duplication. The refactoring in this PR explicitly addresses SonarCloud cognitive complexity issues (commit 75f3625), and the Object.hasOwn compatibility fix is included in the latest commit (4823c93) per the feedback about older browser/WebView compatibility. The 6 new issues reported appear to be lower-priority code quality metrics that do not block the Quality Gate.

@don-petry

Copy link
Copy Markdown
Contributor Author

Fixed both CodeAnt nitpick items:

  1. enrich_community.py:303 — Added exception handling around reddit_token() call to catch network/response errors (URLError, HTTPError, ValueError, KeyError) and wrap them in StageError rather than propagating raw exceptions.

  2. resented_giants.py:250 — Removed the condition that skipped checkpoint saves on unfetched records. The checkpoint now always saves at 10-item intervals regardless of note status, preventing data loss on crash.

Commit: 4dec706

@don-petry

This comment has been minimized.

@don-petry

This comment has been minimized.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry
don-petry enabled auto-merge (squash) October 13, 2026 22:11
@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge October 13, 2026 22:12
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-13T23:12:40Z.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (applied)

Changes committed and pushed. Requested items addressed:

  • pocs/demand-radar/deep_dive.py:229 — applied

@don-petry
don-petry enabled auto-merge (squash) October 13, 2026 22:13
@don-petry
don-petry disabled auto-merge October 13, 2026 22:14
@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 18:04
@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.

@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge October 20, 2026 18:56
@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-20T19:56:35Z.

@don-petry

This comment has been minimized.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (no-changes)

Agent reasoning
Addressed 0 threads. PR #173 had no open review threads, all CI checks passed, and no review has CHANGES_REQUESTED, so there are no Tier 1 blockers.
- **Stale disposition:** I posted a fresh `informational` disposition on CodeRabbit comment `IC_kwDOTWRdAs8AAAABbu56BQ`. Its current body holds only a rate-limit notice, "No actionable comments were generated", and the walkthrough, with no finding-bearing sections.
- **Earlier CodeRabbit finding:** the `reddit_token` `OSError`/`TimeoutError` handling in `pocs/demand-radar/enrich_community.py` was already fixed. `_forced_reddit_token` catches `OSError`, and `pocs/demand-radar/tests/test_enrich_export_pipeline.py` has a `TimeoutError` test. I didn't re-run that test.
- **Test verification:** I didn't run the test suite, since I made no code changes.
- **Files changed:** none, and no commits.

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 18:57
@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.

@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge October 20, 2026 20:34
@don-petry

This comment has been minimized.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (no-changes)

Agent reasoning
Addressed 0 threads (there were no open review threads).
- **CI:** No check has failed. CodeRabbit is still in progress.
- **Reviews:** No `CHANGES_REQUESTED` reviews, so there are no Tier 1 blockers.
- **Stale disposition:** I re-read the current body of the CodeRabbit summary comment `IC_kwDOTWRdAs8AAAABbu56BQ`.
  - **Result:** The summary reports no actionable comments. It has no Security Architecture, nitpick or outside-diff sections.
  - **Earlier finding:** CodeRabbit's earlier review asked for `TimeoutError`/`OSError` from `reddit_token` to be wrapped in `StageError`. That is already in `_forced_reddit_token` in `pocs/demand-radar/enrich_community.py`.
  - **Reply:** I posted one `informational` disposition reply.
- **Test verification:** Skipped, since I made no code changes.
- **Files changed:** none.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-20T21:35:44Z.

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 20:35
@donpetry-bot

donpetry-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

@don-petry
don-petry disabled auto-merge October 20, 2026 21:39
@don-petry

Copy link
Copy Markdown
Contributor Author

CodeRabbit's recent review generated no actionable comments. The SonarCloud Code Analysis CI check has completed successfully on this PR, confirming the analysis was performed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
Issues addressed: 0 (informational notice)
The CodeRabbit bot's edited comment shows:
- Recent code review: "No actionable comments were generated" ✓
- All CI checks passed (including SonarCloud Code Analysis) ✓
- Pre-merge check inconclusive about evidence — addressed via passing SonarCloud CI check
Action: Posted disposition=informational reply to acknowledge clean review result and successful SonarCloud analysis.
Files changed: None
```
The PR is ready — no code changes needed. The bot's recent review found no issues, all CI checks passed, and the disposition clears the bot comment from the maintainer-comment gate.

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 21:40
@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.

@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry

Copy link
Copy Markdown
Contributor Author

Closing as superseded. Issue #168 was closed as completed on 2026-10-20, and SonarCloud reports 0 open python:S3776 (cognitive complexity) findings on main, so this 690+/430- refactor of the DemandRadar spike no longer fixes anything. Its recent commits are only auto-merges of main. Reopen if a new S3776 finding appears.

@don-petry don-petry closed this Oct 22, 2026
auto-merge was automatically disabled October 22, 2026 11:44

Pull request was closed

@don-petry
don-petry deleted the dev-lead/issue-168-20261013-2154 branch October 22, 2026 11:44
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

auto-rebase:ready Opts a non-draft PR into auto-rebase without an approval (auto-rebase ready_label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud: cognitive complexity (S3776)

2 participants