@@ -65,12 +65,12 @@ set_line_break_before_curly_opening <- function(pd) {
6565 ~ next_terminal(pd [.x , ], vars = " token_after" )$ token_after
6666 ) != " '{'"
6767 last_expr_idx <- max(which(pd $ token == " expr" ))
68- is_last_expr <- ifelse(pd $ token [ 1 ] %in% c(" IF" , " WHILE" ),
68+ is_last_expr <- ifelse(any( c(" IF" , " WHILE" ) == pd $ token [ 1 ] ),
6969 # rule not applicable for if and while
7070 TRUE , (line_break_to_set_idx + 1L ) == last_expr_idx
7171 )
7272
73- no_line_break_before_curly_idx <- pd $ token [line_break_to_set_idx ] %in% " EQ_SUB"
73+ no_line_break_before_curly_idx <- any( pd $ token [line_break_to_set_idx ] == " EQ_SUB" )
7474 linebreak_before_curly <- ifelse(is_function_call(pd ),
7575 # if in function call and has pipe, it is not recognized as function call
7676 # and goes to else case
@@ -85,7 +85,7 @@ set_line_break_before_curly_opening <- function(pd) {
8585 no_line_break_before_curly_idx
8686 )
8787 is_not_curly_curly_idx <- line_break_to_set_idx [should_be_on_same_line ]
88- pd $ lag_newlines [1 + is_not_curly_curly_idx ] <- 0L
88+ pd $ lag_newlines [1L + is_not_curly_curly_idx ] <- 0L
8989
9090
9191 # other cases: line breaks
@@ -99,10 +99,10 @@ set_line_break_before_curly_opening <- function(pd) {
9999 ]
100100 if (is_function_dec(pd )) {
101101 should_not_be_on_same_line_idx <- setdiff(
102- 1 + should_not_be_on_same_line_idx , nrow(pd )
102+ 1L + should_not_be_on_same_line_idx , nrow(pd )
103103 )
104104 } else {
105- should_not_be_on_same_line_idx <- 1 + should_not_be_on_same_line_idx
105+ should_not_be_on_same_line_idx <- 1L + should_not_be_on_same_line_idx
106106 }
107107 pd $ lag_newlines [should_not_be_on_same_line_idx ] <- 1L
108108
@@ -150,7 +150,7 @@ set_line_break_around_comma_and_or <- function(pd, strict) {
150150}
151151
152152style_line_break_around_curly <- function (strict , pd ) {
153- if (is_curly_expr(pd ) && nrow(pd ) > 2 ) {
153+ if (is_curly_expr(pd ) && nrow(pd ) > 2L ) {
154154 closing_before <- pd $ token == " '}'"
155155 opening_before <- (pd $ token == " '{'" )
156156 to_break <- lag(opening_before , default = FALSE ) | closing_before
0 commit comments