Skip to content
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

fix: use || operator instead of unreachable ?? #2845

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Conversation

agatha197
Copy link
Contributor

@agatha197 agatha197 commented Nov 12, 2024

Fix Right operand of ?? is unreachable because the left operand is never nullish. error by using || operator.

Checklist: (if applicable)

  • Mention to the original issue
  • Documentation
  • Minium required manager version
  • Specific setting for review (eg., KB link, endpoint or how to setup)
  • Minimum requirements to check during review
  • Test case(s) to demonstrate the difference of before/after

Copy link

graphite-app bot commented Nov 12, 2024

Your org requires the Graphite merge queue for merging into main

Add the label “flow:merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “flow:hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Contributor Author

agatha197 commented Nov 12, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the size:XS ~10 LoC label Nov 12, 2024
@agatha197 agatha197 added the type:fix Fix features that are not working label Nov 12, 2024 — with Graphite App
Copy link

github-actions bot commented Nov 12, 2024

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements 5.29% 395/7462
🔴 Branches
4.59% (-0% 🔻)
237/5166
🔴 Functions 3.16% 78/2466
🔴 Lines 5.21% 380/7295

Test suite run success

124 tests passing in 14 suites.

Report generated by 🧪jest coverage report action from ae54e8a

Comment on lines 96 to 100
((iSizeToSize(_.toString(agent?.mem_cur_bytes), 'g')
?.number ?? 0) /
(iSizeToSize(parsedAvailableSlots?.mem, 'g')?.number ??
?.number || 0) /
(iSizeToSize(parsedAvailableSlots?.mem, 'g')?.number ||
0)) *
100 ?? 0
100
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
((iSizeToSize(_.toString(agent?.mem_cur_bytes), 'g')
?.number ?? 0) /
(iSizeToSize(parsedAvailableSlots?.mem, 'g')?.number ??
?.number || 0) /
(iSizeToSize(parsedAvailableSlots?.mem, 'g')?.number ||
0)) *
100 ?? 0
100
(_.toNumber(
iSizeToSize(_.toString(agent?.mem_cur_bytes), 'g')
?.number,
) /
_.toNumber(
iSizeToSize(parsedAvailableSlots?.mem, 'g')?.number,
)) *
100 || 0

To further improve, instead of using || 0 to handle NaN, we can modify BAIProgressWithLabel to display the percent as disabled or distinguish it in some way when it is NaN.

@github-actions github-actions bot added size:S 10~30 LoC and removed size:XS ~10 LoC labels Nov 14, 2024
@github-actions github-actions bot added size:M 30~100 LoC and removed size:S 10~30 LoC labels Nov 21, 2024
Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

I pushed a commit to fix condition. Please check it. Now, LGTM! 💪 🙏

Copy link

graphite-app bot commented Nov 21, 2024

Merge activity

Fix `Right operand of ?? is unreachable because the left operand is never nullish.` error by using `||` operator.

**Checklist:** (if applicable)

- [ ] Mention to the original issue
- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
@graphite-app graphite-app bot merged commit ae54e8a into main Nov 21, 2024
7 checks passed
@graphite-app graphite-app bot deleted the fix/nullish-value branch November 21, 2024 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M 30~100 LoC type:fix Fix features that are not working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants