Skip to content

Commit 8586191

Browse files
style with styler.
1 parent bbc921e commit 8586191

File tree

8 files changed

+40
-43
lines changed

8 files changed

+40
-43
lines changed

R/indent.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ indent_without_paren <- function(pd, indent_by = 2) {
8787
#' definitions without parenthesis.
8888
#' @keywords internal
8989
indent_without_paren_for_while_fun <- function(pd, indent_by) {
90-
9190
tokens <- c("FOR", "WHILE", "FUNCTION")
9291
nrow <- nrow(pd)
9392
if (!(pd$token[1] %in% tokens)) {
@@ -97,7 +96,7 @@ indent_without_paren_for_while_fun <- function(pd, indent_by) {
9796
return(pd)
9897
}
9998

100-
if (pd$newlines[length(pd$newlines) - 1] == 0 ) {
99+
if (pd$newlines[length(pd$newlines) - 1] == 0) {
101100
return(pd)
102101
}
103102
pd$indent[nrow] <- indent_by

R/rules-line-break.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ remove_line_break_before_curly_opening <- function(pd) {
33
rm_break_idx <- which((pd$token_after == "'{'") & (pd$token != "COMMENT"))
44
rm_break_idx <- setdiff(rm_break_idx, nrow(pd))
55
if (length(rm_break_idx) > 0) {
6-
is_not_curly_curly <- map_chr(rm_break_idx + 1L,
7-
~next_terminal(pd[.x,], vars = "token_after")$token_after
6+
is_not_curly_curly <- map_chr(
7+
rm_break_idx + 1L,
8+
~ next_terminal(pd[.x, ], vars = "token_after")$token_after
89
) != "'{'"
910
is_not_curly_curly_idx <- rm_break_idx[is_not_curly_curly]
1011
pd$lag_newlines[1 + is_not_curly_curly_idx] <- 0L
@@ -104,7 +105,7 @@ remove_line_break_before_round_closing_fun_dec <- function(pd) {
104105
add_line_break_after_pipe <- function(pd) {
105106
is_pipe <- pd$token == c("SPECIAL-PIPE") & pd$token_after != "COMMENT"
106107
if (sum(is_pipe) > 1 &&
107-
!(next_terminal(pd, vars = "token_before")$token_before %in% c("'('", "EQ_SUB", "','"))) {
108+
!(next_terminal(pd, vars = "token_before")$token_before %in% c("'('", "EQ_SUB", "','"))) {
108109
pd$lag_newlines[lag(is_pipe)] <- 1L
109110
}
110111
pd

R/rules-spacing.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ set_space_around_op <- function(pd_flat, strict) {
1717
return(pd_flat)
1818
}
1919
if (sum(pd_flat$lag_newlines) > 2 &&
20-
is_function_call(pd_flat) &&
21-
any(pd_flat$token %in% c("EQ_SUB", "','"))
20+
is_function_call(pd_flat) &&
21+
any(pd_flat$token %in% c("EQ_SUB", "','"))
2222
) {
2323
is_on_aligned_line <- token_is_on_aligned_line(pd_flat)
2424
} else {
@@ -179,7 +179,6 @@ add_space_after_for_if_while <- function(pd_flat) {
179179
#' @keywords internal
180180
set_space_in_curly_curly <- function(pd) {
181181
if (is_curly_expr(pd)) {
182-
183182
after_inner_opening <- pd$token == "'{'" & pd$token_before == "'{'"
184183
before_inner_closing <- lead(pd$token == "'}'" & pd$token_after == "'}'")
185184
is_curly_curly_inner <- any(after_inner_opening, na.rm = TRUE) &&

R/serialize.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#' @keywords internal
77
serialize_parse_data_flattened <- function(flattened_pd, start_line = 1) {
88
flattened_pd$lag_newlines[1] <- start_line - 1
9-
res <- with(flattened_pd,
9+
res <- with(
10+
flattened_pd,
1011
paste0(
1112
collapse = "",
1213
map(lag_newlines, add_newlines), map(lag_spaces, add_spaces), text

R/testing-mocks.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#'`style_text()` without rules for `\{\{`
1+
#' `style_text()` without rules for `\{\{`
22
#'
33
#' This function mocks [style_text()], but without taking into consideration the
44
#' rules for the curly-curly syntactic sugar (introduced in rlang 0.4).
@@ -29,7 +29,7 @@ style_text_without_curly_curly <- function(text,
2929
}
3030
transformers$line_break$set_line_break_around_curly_curly <- NULL
3131
style_text(text, ...,
32-
style = NULL, transformers = transformers,
33-
include_roxygen_examples = include_roxygen_examples
32+
style = NULL, transformers = transformers,
33+
include_roxygen_examples = include_roxygen_examples
3434
)
3535
}

R/testing-public-api.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ catch_style_file_output <- function(file_in = c(
2727
raw_output <- withr::with_dir(
2828
dirname(temp_path),
2929
capture.output(
30-
style_file(basename(temp_path), scope = "tokens")
31-
))
30+
style_file(basename(temp_path), scope = "tokens")
31+
)
32+
)
3233
unlink(dirname(temp_path))
3334
raw_output
3435
}

R/token-define.R

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
token <- tribble(
2-
~text , ~class , ~token ,
3-
"&" , "logical" , "AND" ,
4-
"&&" , "logical" , "AND2" ,
5-
"|" , "logical" , "OR" ,
6-
"||" , "logical" , "OR2" ,
7-
">" , "logical" , "GT" ,
8-
"<" , "logical" , "LT" ,
9-
"<=" , "logical" , "LE" ,
10-
">=" , "logical" , "GE" ,
11-
"!=" , "logical" , "NE" ,
12-
"==" , "logical" , "EQ" ,
13-
"=" , "assign_left" , "EQ_SUB" ,
14-
"=" , "assign_left" , "EQ_ASSIGN" ,
15-
"<-" , "assign_left" , "LEFT_ASSIGN" ,
16-
"->" , "assign_right", "RIGHT_ASSIGN",
17-
"+" , "math" , "'+'" ,
18-
"-" , "math" , "'-'" ,
19-
"*" , "math" , "'*'" ,
20-
"/" , "math" , "'/'" ,
21-
"^" , "math" , "'^'" ,
22-
"~" , "formula" , "'~'" ,
23-
"if" , "cond" , "IF" ,
24-
"else" , "cond" , "ELSE" ,
25-
"in" , "loop_cond" , "IN" ,
26-
"while", "loop_cond" , "WHILE"
2+
~text, ~class, ~token,
3+
"&", "logical", "AND",
4+
"&&", "logical", "AND2",
5+
"|", "logical", "OR",
6+
"||", "logical", "OR2",
7+
">", "logical", "GT",
8+
"<", "logical", "LT",
9+
"<=", "logical", "LE",
10+
">=", "logical", "GE",
11+
"!=", "logical", "NE",
12+
"==", "logical", "EQ",
13+
"=", "assign_left", "EQ_SUB",
14+
"=", "assign_left", "EQ_ASSIGN",
15+
"<-", "assign_left", "LEFT_ASSIGN",
16+
"->", "assign_right", "RIGHT_ASSIGN",
17+
"+", "math", "'+'",
18+
"-", "math", "'-'",
19+
"*", "math", "'*'",
20+
"/", "math", "'/'",
21+
"^", "math", "'^'",
22+
"~", "formula", "'~'",
23+
"if", "cond", "IF",
24+
"else", "cond", "ELSE",
25+
"in", "loop_cond", "IN",
26+
"while", "loop_cond", "WHILE"
2727
)
2828

2929
math_token <- token$token[token$class == "math"]
@@ -66,6 +66,3 @@ op_token <- c(
6666
"EQ_SUB", "ELSE", "IN",
6767
"EQ_FORMALS"
6868
)
69-
70-
71-

R/transform-files.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ parse_transform_serialize_r <- function(text, transformers, warn_empty = TRUE) {
215215
#' @importFrom purrr flatten
216216
#' @keywords internal
217217
apply_transformers <- function(pd_nested, transformers) {
218-
219218
transformed_updated_multi_line <- post_visit(
220219
pd_nested,
221220
c(transformers$initialize, transformers$line_break, set_multi_line, update_newlines)

0 commit comments

Comments
 (0)