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

lint x %in% NA in equals_na_linter #2112

Merged
merged 6 commits into from
Sep 7, 2023
Merged

lint x %in% NA in equals_na_linter #2112

merged 6 commits into from
Sep 7, 2023

Conversation

MichaelChirico
Copy link
Collaborator

Closes #2088

In writing this I had three follow-up questions

  1. Should we customize the lint message for %in%/==/!= (yes)
  2. Should we lint x %in% c(NA, y) to encourage is.na(x) | x %in% y (I think no)
  3. Should we lint NA %in% x (should be anyNA(x); I am less sure, maybe it could go under any_is_na_linter()?)

@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2023

Codecov Report

Merging #2112 (7bfc14f) into main (99fdd85) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 7bfc14f differs from pull request most recent head e252ee2. Consider uploading reports for the commit e252ee2 to get more accurate results

@@           Coverage Diff           @@
##             main    #2112   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files         120      120           
  Lines        5240     5242    +2     
=======================================
+ Hits         5222     5224    +2     
  Misses         18       18           
Files Changed Coverage Δ
R/equals_na_linter.R 100.00% <100.00%> (ø)

📢 Have feedback on the report? Share it here.

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.

Re 3.: I Agree it should be linted in the any_is_na_linter()

tests/testthat/test-equals_na_linter.R Outdated Show resolved Hide resolved
@AshesITR
Copy link
Collaborator

AshesITR commented Sep 7, 2023

Also should test that NA %in% x doesn't lint here.

@MichaelChirico
Copy link
Collaborator Author

Follow-ups:

#2113
#2114

@MichaelChirico
Copy link
Collaborator Author

Also should test that NA %in% x doesn't lint here.

Good call -- the logic was broken (==/!= throw lint for NA on LHS or LHS of the operator, not so for %in%). Done now

@AshesITR AshesITR merged commit 68b82ce into main Sep 7, 2023
21 checks passed
@AshesITR AshesITR deleted the eq-na-in branch September 7, 2023 19:28
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.

throw equals_na_linter() for x %in% NA
3 participants