Fix false positive in if_switch_linter() for empty strings#3018
Merged
MichaelChirico merged 8 commits intomainfrom Mar 2, 2026
Merged
Fix false positive in if_switch_linter() for empty strings#3018MichaelChirico merged 8 commits intomainfrom
if_switch_linter() for empty strings#3018MichaelChirico merged 8 commits intomainfrom
Conversation
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
c3a9da2 to
ac74b25
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3018 +/- ##
=======================================
Coverage 99.23% 99.23%
=======================================
Files 128 128
Lines 7293 7317 +24
=======================================
+ Hits 7237 7261 +24
Misses 56 56 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
MichaelChirico
approved these changes
Mar 2, 2026
Collaborator
MichaelChirico
left a comment
There was a problem hiding this comment.
Looking great! I found the original test suite a bit lacking so added a few more tests too as better assurance against backsliding elsewhere from the refactor.
Explaining my tweaks to the helper names:
- I think it's good to emphasize this is specifically an
if_elsechain - Hadley influenced me to dislike
get_in function names. I tend to agree it's usually redundant. vardoesn't precisely match the case likeif (foo(x) == 'a') else if (foo(x) == 'b'), I thinkexpris better
Collaborator
Author
|
@MichaelChirico thanks on all the the guidance on this! |
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.
PR Summay
if_switch_linter()was flagging if-else chains that compare against empty strings (""or''), but we can't actually use empty strings asswitch()case names as R throws an error. This PR skips those cases so the linter only suggestsswitch()when it's actually valid.Fixes #2835