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

New coalesce_linter for encouraging %||% #2767

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Feb 20, 2025

Closes #2246. Using coalesce_linter() over null_coalescing_linter() to facilitate future extensions to other types of coalescing.

@MichaelChirico

This comment was marked as outdated.

Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

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

Doesn't coalesce imply NULLs are replaced?

@AshesITR
Copy link
Collaborator

We could later expand this to ifelse(), if_else(), fifelse() and case_when(), all of which I've seen abused to coalesce.

Similarly the vectorized variants for dplyr if_else(is.na(x), y, x) == coalesce(x, y) and data.table fifelse(is.na(x), y, x) == fcoalesce(x, y).

@MichaelChirico
Copy link
Collaborator Author

We could later expand this to ifelse(), if_else(), fifelse() and case_when(), all of which I've seen abused to coalesce.

Similarly the vectorized variants for dplyr if_else(is.na(x), y, x) == coalesce(x, y) and data.table fifelse(is.na(x), y, x) == fcoalesce(x, y).

So maybe this should just be called coalesce_linter() after all, to anticipate future use cases, WDYT @IndrajeetPatil?

@MichaelChirico MichaelChirico changed the title New null_coalescing_linter for encouraging %||% New coalesce_linter for encouraging %||% Feb 26, 2025
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.

Project coverage is 99.59%. Comparing base (3a1e48b) to head (0495900).

Files with missing lines Patch % Lines
R/utils.R 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2767   +/-   ##
=======================================
  Coverage   99.59%   99.59%           
=======================================
  Files         125      126    +1     
  Lines        6835     6869   +34     
=======================================
+ Hits         6807     6841   +34     
  Misses         28       28           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New linter encouraging %||%
2 participants