feat: implement issue #56 — SonarCloud: cognitive complexity (S3776) - #60
feat: implement issue #56 — SonarCloud: cognitive complexity (S3776)#60don-petry wants to merge 12 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThe PR refactors discovery, extraction, and flattening helpers. It adds offline tests, generates ChangesScript helper refactor
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors discover.py, extract_all.py, and flatten.py by extracting several helper functions from their respective main() functions to reduce cognitive complexity. It also introduces a comprehensive suite of unit tests in tests/test_refactor_helpers.py to lock in the behavior of these helpers. The review feedback highlights several edge cases regarding falsy values, such as handling None for apiaries in discover.py and correctly checking for None instead of falsy 0 timestamps in flatten.py to prevent bugs with epoch timestamps. Additionally, it suggests adding a test case to verify graceful handling of None inputs.
Dev-Lead — review-changes (applied)Changes committed and pushed. |
There was a problem hiding this comment.
Pull request overview
Refactors the three CLI scripts’ main() flows to reduce SonarCloud cognitive complexity (python:S3776) without changing runtime behavior, and adds offline unit tests that lock in the extracted helper behavior.
Changes:
scripts/discover.py: Extracted apiary-tree walking and endpoint sampling into helpers (walk_sample_ids,sample_endpoint).scripts/extract_all.py: Extracted window fetching, progress logging, and reverse-backfill early-exit bookkeeping into helpers (fetch_window,process_hive, etc.).scripts/flatten.py: Extracted pass-1 metric discovery, pass-2 streaming/dedup/coverage updates, notes writing, and coverage serialization into helpers;main()now delegates to these helpers.- Added offline pytest coverage for the new helpers across all three scripts.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_refactor_helpers.py | New offline unit tests validating helper behavior for discover/extract/flatten refactors. |
| scripts/discover.py | Pulls complex nested traversal and repeated try/except sampling into dedicated helpers. |
| scripts/extract_all.py | Moves per-hive window processing (budget handling, early-exit, persistence cadence) into helpers. |
| scripts/flatten.py | Splits the two-pass flattening pipeline into composable functions (discovery, streaming, notes, coverage). |
Dev-Lead — review-changes (applied)Changes committed and pushed. |
Dev-Lead Fix CI — failedPR: #60 | SHA: |
Dev-Lead — fix-bot-comment (applied)Changes committed and pushed. |
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |
Dev-Lead — review-changes (applied)Changes committed and pushed. |
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |
Superseded by automated re-review at
|
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |
Superseded by automated re-review at
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Dev-Lead — review-changes (no-changes)No changes were needed for this PR. |
Review — fix requested (cycle 3/3)The automated review identified the following issues. Please address each one: Findings to fixAutomated review — NEEDS HUMAN REVIEWRisk: MEDIUM SummaryThird-cycle review at Linked issue analysisCloses #56 (SonarCloud cognitive-complexity S3776). The refactor substantively addresses the issue: FindingsBlocking (carried forward from cycles 1 and 2, NOT resolved)
Non-blocking (carried forward, unchanged) New since prior review: merge of MCP secret-scanning tool unavailable in this run; gitleaks CI check is green. CI statusAll checks green at Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review. Additional tasks
The review cascade will automatically re-review after new commits are pushed. |



User description
Closes #56
Implemented by dev-lead agent. Please review.
Summary by CodeRabbit
Improvements
Testing
Chores
CodeAnt-AI Description
Make data extraction resumable and exports reliable across API response shapes
What Changed
Impact
✅ Fewer duplicate reading rows✅ Resumable API extraction✅ Clearer discovery failures💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.