Refactor (packages/ui/src/v2/components/tooltip-v2.tsx): Function with many returns - #53
Open
amrashee wants to merge 1 commit into
Open
Refactor (packages/ui/src/v2/components/tooltip-v2.tsx): Function with many returns#53amrashee wants to merge 1 commit into
amrashee wants to merge 1 commit into
Conversation
amrashee
force-pushed
the
refactor-tooltip-returns
branch
from
September 3, 2026 19:08
03c530d to
8286ff5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #20
Type of change
What does this PR do?
Please provide a description of the issue, the changes you made to fix it, and why they work. It is expected that you understand why your changes work and if you do not understand why at least say as much so a maintainer knows how much to value the PR.
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
Qlty reported that TooltipV2 had too many returns. I changed the drop logic so it uses a helper called shouldDropBlock instead of having multiple early returns. The helper checks if the tooltip is expanded, hovered, or has focus inside. If any of these are true, the block stays. This keeps the same behavior but removes the Qlty smell I claimed.
-Before: 'Function with many returns (count = 8): TooltipV2'
-After: the "Function with many returns" smell is no longer reported.
How did you verify your code works?
I added tests for the different cases in shouldDropBlock. The new tests passed (4/4), and I also ran the full UI tests which passed (31/31). I ran coverage as well and the new helper has 100% line and function coverage. I also ran Qlty again to make sure the smell was gone.
Screenshots / recordings
Before Qlty:
After Qlty:
Tests:
Coverage:
Bun lint: bun lint reports 698 warnings and 2 errors. I checked the untouched upstream main branch and got the same result. Professor Eduardo confirmed that the 2 errors were already part of the codebase and do not need to be fixed.
If this is a UI change, please include a screenshot or recording.
There is no visual change.
Checklist
If you do not follow this template your PR will be automatically rejected.