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

unnecessary_placeholder_linter() could cover other magrittr operators too #1657

Closed
MichaelChirico opened this issue Oct 10, 2022 · 1 comment
Labels
false-negative code that should lint, but doesn't

Comments

@MichaelChirico
Copy link
Collaborator

MichaelChirico commented Oct 10, 2022

Follow-up to #1656

IINM, %<>% and %T>% should work out of the box if we expand text() in XPath.

The %$% is a bit more tricky and can possibly be dealt with separately.

WDYT?

library(magrittr)

y <- 1
y %<>% sum(., 1) # lint
y
#> [1] 2

z <- 1
z %<>% sum(1)
z
#> [1] 2

# N.B. removing plots output manually to keep the reprex clean
1 %T>% plot %>% sum(1)
#> [1] 2
1 %T>% plot() %>% sum(1)
#> [1] 2
1 %T>% plot(.) %>% sum(1) # lint
#> [1] 2

mtcars %$% cor(wt, mpg)
#> [1] -0.8676594
mtcars %$% cor(.$wt, .$mpg) # lint
#> [1] -0.8676594

<sup>Created on 2022-10-10 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>

Originally posted by @IndrajeetPatil in #1656 (comment)

@MichaelChirico MichaelChirico added the false-negative code that should lint, but doesn't label Oct 10, 2022
MichaelChirico added a commit that referenced this issue Oct 11, 2022
* `unnecessary_placeholder_linter()` covers a few other ops

Part of #1657

* Update test-unnecessary_placeholder_linter.R

* remove skip

* document which pipes

Co-authored-by: Michael Chirico <[email protected]>
@IndrajeetPatil IndrajeetPatil changed the title unnecessary_placeholder_linter() could cover other magrittr operators too unnecessary_placeholder_linter() could cover other magrittr operators too Nov 26, 2022
@MichaelChirico
Copy link
Collaborator Author

This was done in #2046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-negative code that should lint, but doesn't
Projects
None yet
Development

No branches or pull requests

1 participant