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 unnecessary_placeholder_linter #1656

Merged
merged 4 commits into from
Oct 10, 2022
Merged

New unnecessary_placeholder_linter #1656

merged 4 commits into from
Oct 10, 2022

Conversation

MichaelChirico
Copy link
Collaborator

Part of #884

Originally named MagrittrDotLinter(), I think the new name is an improvement (and paves the way for base's _ to be included), but open to further refinement here.

@codecov-commenter
Copy link

Codecov Report

Merging #1656 (bc78d68) into main (e05d994) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1656   +/-   ##
=======================================
  Coverage   98.49%   98.50%           
=======================================
  Files         101      102    +1     
  Lines        4456     4478   +22     
=======================================
+ Hits         4389     4411   +22     
  Misses         67       67           
Impacted Files Coverage Δ
R/unnecessary_placeholder_linter.R 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@IndrajeetPatil
Copy link
Collaborator

Do you think we should also expand this linter to cover other operators from {magrittr}?

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>

@MichaelChirico
Copy link
Collaborator Author

Agree we could add those, thanks for the suggestion! let's file follow-ups for those

@IndrajeetPatil IndrajeetPatil merged commit 83ef5b8 into main Oct 10, 2022
@IndrajeetPatil IndrajeetPatil deleted the magdo branch October 10, 2022 08:19
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.

3 participants