simplify code for hover and click parsing#238
Conversation
📝 WalkthroughWalkthroughThe PR simplifies three interconnected functions in ChangesHover Info & Time Calculation Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). Review rate limit: 9/10 reviews remaining, refill in 6 minutes. Comment |
There was a problem hiding this comment.
Code Review
This pull request simplifies the xy_str and imgDrugTime functions in R/app_server.R by removing several safety checks and fallback logic. The review feedback highlights that these changes introduce potential runtime errors, specifically regarding zero-length logical vectors in conditional statements, and reduce the robustness of the hover functionality when drug data is unavailable. It is recommended to restore the safety checks to prevent silent failures and crashes.
|
Preview Deployment This PR has been deployed to: https://steveshafer.shinyapps.io/stanpumpr_PR_238/ This deployment will be automatically cleaned up when the PR is closed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@R/app_server.R`:
- Around line 721-723: The code indexes plottedDrugs[1] without guarding for an
empty allResultsReactive(), so firstDrug can be NA and accessing
drugs()[[firstDrug]]$equiSpace$Time will error; restore the earlier empty-result
fallback by checking that plottedDrugs is non-empty (or that
allResultsReactive() has results) before using plottedDrugs[1]; if empty, set a
safe default (e.g., return/exit the handler or set time to NA) so the
click/double-click handler can still open its modal without crashing. Ensure the
guard surrounds the block that uses firstDrug and references plottedDrugs,
firstDrug, drugs(), and equiSpace$Time.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Summary by CodeRabbit