-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imavid: return 0 instead of NaN if total frames is 1 or 0 #5442
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/packages/playback/src/lib/use-timeline-viz-utils.ts (1)
Line range hint
52-62
: Consider adding JSDoc comments to document the edge cases.While the implementation is correct, it would be helpful to document the behavior for edge cases in the function's JSDoc comments.
Add documentation like this:
+/** + * Converts a frame number to a percentage (0-100) based on total frames. + * @param frameNumber - The current frame number (1-based indexing) + * @param totalFrames - The total number of frames + * @returns The percentage (0-100) or 0 if total frames is 1 or less + */ export const convertFrameNumberToPercentage = ( frameNumber: number, totalFrames: number ) => {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/packages/playback/src/lib/use-timeline-viz-utils.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/playback/src/lib/use-timeline-viz-utils.ts (1)
Pattern **/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: lint / eslint
- GitHub Check: e2e / test-e2e
- GitHub Check: test / test-python (ubuntu-latest-m, 3.10)
- GitHub Check: test / test-app
- GitHub Check: build / build
🔇 Additional comments (1)
app/packages/playback/src/lib/use-timeline-viz-utils.ts (1)
55-59
: LGTM! Good handling of edge cases.The guard clause effectively prevents division by zero when total frames is 1 or 0, returning 0 instead of NaN. This is a robust solution that maintains type safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. convertFrameNumberToPercentage
is an easy function to add unit tests for 😄
minor bugfix to prevent cases where NaN might be returned as a result of division by zero
Summary by CodeRabbit