Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Do not replace <- with = if within a function call since it has other…
Browse files Browse the repository at this point in the history
… meaning.
  • Loading branch information
lorenzwalthert committed May 12, 2019
1 parent 463100f commit 5bf20ab
Show file tree
Hide file tree
Showing 6 changed files with 302 additions and 260 deletions.
6 changes: 4 additions & 2 deletions R/rules-replacement.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ force_assignment_op <- function(pd) {

force_assignment_eq <- function(pd) {
to_replace <- pd$token == "LEFT_ASSIGN" & pd$text == "<-"
pd$token[to_replace] <- "EQ_ASSIGN"
pd$text[to_replace] <- "="
if (any(to_replace) && next_terminal(pd)$token == "'('") {
pd$token[to_replace] <- "EQ_ASSIGN"
pd$text[to_replace] <- "="
}
pd
}

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/mlr-style/eq-sub-replacement-in.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
c(a <- 3)
(a = b)
((a = 3))
33 changes: 33 additions & 0 deletions tests/testthat/mlr-style/eq-sub-replacement-in_tree

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/testthat/mlr-style/eq-sub-replacement-out.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
c(a <- 3)
(a = b)
((a = 3))
Loading

0 comments on commit 5bf20ab

Please sign in to comment.