Skip to content

Commit 9123afe

Browse files
Improve a few function names
We are being unnecessarily terse in some places where we don't need to be. I always feel like I am hitting a little speed bump every time I need to decode these names mentally.
1 parent 4e3bc30 commit 9123afe

9 files changed

+37
-37
lines changed

R/rules-indention.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ indent_braces <- function(pd, indent_by) {
1616
#' Necessary for consistent indention of the function declaration header.
1717
#' @param pd A parse table.
1818
#' @inheritParams is_single_indent_function_declaration
19-
#' @seealso set_unindention_child update_indention_ref_fun_dec
19+
#' @seealso set_unindention_child update_indention_reference_function_declaration
2020
#' @keywords internal
21-
unindent_fun_dec <- function(pd, indent_by = 2L) {
21+
unindent_function_declaration <- function(pd, indent_by = 2L) {
2222
if (is_function_declaration(pd)) {
2323
idx_closing_brace <- which(pd$token == "')'")
2424
fun_dec_head <- seq2(2L, idx_closing_brace)
@@ -133,7 +133,7 @@ NULL
133133
#' }
134134
#'
135135
#' @keywords internal
136-
update_indention_ref_fun_dec <- function(pd_nested) {
136+
update_indention_reference_function_declaration <- function(pd_nested) {
137137
if (is_function_declaration(pd_nested) && !is_single_indent_function_declaration(pd_nested)) {
138138
seq <- seq2(3L, nrow(pd_nested) - 2L)
139139
pd_nested$indention_ref_pos_id[seq] <- pd_nested$pos_id[2L]

R/rules-line-breaks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ remove_line_break_before_round_closing_after_curly <- function(pd) {
234234
pd
235235
}
236236

237-
remove_line_breaks_in_fun_dec <- function(pd) {
237+
remove_line_breaks_in_function_declaration <- function(pd) {
238238
if (is_function_declaration(pd)) {
239239
is_single_indention <- is_single_indent_function_declaration(pd)
240240
round_after <- (

R/rules-spaces.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @include token-define.R
55
#' @keywords internal
66
#' @include token-define.R
7-
set_space_around_op <- function(pd_flat, strict) {
7+
set_space_around_operator <- function(pd_flat, strict) {
88
# spacing and operator in same function because alternative is
99
# calling token_is_on_aligned_line() twice because comma and operator spacing
1010
# depends on it.
@@ -122,7 +122,7 @@ style_space_around_tilde <- function(pd_flat, strict) {
122122
pd_flat
123123
}
124124

125-
remove_space_after_unary_pm_nested <- function(pd) {
125+
remove_space_after_unary_plus_minus_nested <- function(pd) {
126126
if (any(pd$token[1L] %in% c("'+'", "'-'"))) {
127127
pd$spaces[1L] <- 0L
128128
}
@@ -349,7 +349,7 @@ remove_space_around_dollar <- function(pd_flat) {
349349
pd_flat
350350
}
351351

352-
remove_space_after_fun_dec <- function(pd_flat) {
352+
remove_space_after_function_declaration <- function(pd_flat) {
353353
fun_after <- (pd_flat$token == "FUNCTION") & (pd_flat$lag_newlines == 0L)
354354
pd_flat$spaces[fun_after] <- 0L
355355
pd_flat

R/rules-tokens.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ add_brackets_in_pipe_one <- function(pd, pos) {
6464
#' @param indent_by The amount of spaces used to indent an expression in curly
6565
#' braces. Used for unindention.
6666
#' @keywords internal
67-
wrap_if_else_while_for_fun_multi_line_in_curly <- function(pd, indent_by = 2L) {
67+
wrap_if_else_while_for_function_multi_line_in_curly <- function(pd, indent_by = 2L) {
6868
key_token <- NULL
6969

7070
if (is_for_expr(pd)) {
@@ -88,7 +88,7 @@ wrap_if_else_while_for_fun_multi_line_in_curly <- function(pd, indent_by = 2L) {
8888

8989
#' Wrap a multi-line statement in curly braces
9090
#'
91-
#' @inheritParams wrap_if_else_while_for_fun_multi_line_in_curly
91+
#' @inheritParams wrap_if_else_while_for_function_multi_line_in_curly
9292
#' @inheritParams wrap_subexpr_in_curly
9393
#' @param key_token The token that comes right before the token that contains
9494
#' the expression to be wrapped (ignoring comments). For if and while loops,

R/style-guides.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ tidyverse_style <- function(scope = "tokens",
7676
indention_manipulators <- if ("indention" %in% scope) {
7777
list(
7878
indent_braces = partial(indent_braces, indent_by = indent_by),
79-
unindent_fun_dec = unindent_fun_dec,
79+
unindent_function_declaration = unindent_function_declaration,
8080
indent_op = partial(indent_op, indent_by = indent_by),
8181
indent_eq_sub = partial(indent_eq_sub, indent_by = indent_by),
8282
indent_without_paren = partial(indent_without_paren,
8383
indent_by = indent_by
8484
),
85-
update_indention_ref_fun_dec = update_indention_ref_fun_dec
85+
update_indention_reference_function_declaration = update_indention_reference_function_declaration
8686
)
8787
}
8888
space_manipulators <- if ("spaces" %in% scope) {
@@ -102,19 +102,19 @@ tidyverse_style <- function(scope = "tokens",
102102
style_space_around_tilde,
103103
strict = strict
104104
),
105-
spacing_around_op = purrr::partial(set_space_around_op,
105+
spacing_around_op = purrr::partial(set_space_around_operator,
106106
strict = strict
107107
),
108108
remove_space_after_opening_paren = remove_space_after_opening_paren,
109109
remove_space_after_excl = remove_space_after_excl,
110110
set_space_after_bang_bang = set_space_after_bang_bang,
111111
remove_space_around_dollar = remove_space_around_dollar,
112-
remove_space_after_fun_dec = remove_space_after_fun_dec,
112+
remove_space_after_function_declaration = remove_space_after_function_declaration,
113113
remove_space_around_colons = remove_space_around_colons,
114114
start_comments_with_space = partial(start_comments_with_space,
115115
force_one = start_comments_with_one_space
116116
),
117-
remove_space_after_unary_pm_nested = remove_space_after_unary_pm_nested,
117+
remove_space_after_unary_plus_minus_nested = remove_space_after_unary_plus_minus_nested,
118118
spacing_before_comments = if (strict) {
119119
set_space_before_comments
120120
} else {
@@ -137,8 +137,8 @@ tidyverse_style <- function(scope = "tokens",
137137
set_line_break_before_curly_opening = set_line_break_before_curly_opening,
138138
remove_line_break_before_round_closing_after_curly =
139139
if (strict) remove_line_break_before_round_closing_after_curly,
140-
remove_line_breaks_in_fun_dec =
141-
if (strict) remove_line_breaks_in_fun_dec,
140+
remove_line_breaks_in_function_declaration =
141+
if (strict) remove_line_breaks_in_function_declaration,
142142
set_line_breaks_between_top_level_exprs =
143143
if (strict) set_line_breaks_between_top_level_exprs,
144144
style_line_break_around_curly = partial(
@@ -180,10 +180,10 @@ tidyverse_style <- function(scope = "tokens",
180180
force_assignment_op = force_assignment_op,
181181
resolve_semicolon = resolve_semicolon,
182182
add_brackets_in_pipe = add_brackets_in_pipe,
183-
wrap_if_else_while_for_fun_multi_line_in_curly =
183+
wrap_if_else_while_for_function_multi_line_in_curly =
184184
if (strict) {
185185
purrr::partial(
186-
wrap_if_else_while_for_fun_multi_line_in_curly,
186+
wrap_if_else_while_for_function_multi_line_in_curly,
187187
indent_by = indent_by
188188
)
189189
}
@@ -206,23 +206,23 @@ tidyverse_style <- function(scope = "tokens",
206206
remove_space_after_excl = "'!'",
207207
set_space_after_bang_bang = "'!'",
208208
remove_space_around_dollar = "'$'",
209-
remove_space_after_fun_dec = "FUNCTION",
209+
remove_space_after_function_declaration = "FUNCTION",
210210
remove_space_around_colons = c("':'", "NS_GET_INT", "NS_GET"),
211211
start_comments_with_space = "COMMENT",
212-
remove_space_after_unary_pm_nested = c("'+'", "'-'"),
212+
remove_space_after_unary_plus_minus_nested = c("'+'", "'-'"),
213213
spacing_before_comments = "COMMENT",
214214
set_space_in_curly = c("'{'", "'}'")
215215
),
216216
indention = list(
217217
# indent_braces = c("'('", "'['", "'{'", "')'", "']'", "'}'"),
218-
unindent_fun_dec = "FUNCTION",
218+
unindent_function_declaration = "FUNCTION",
219219
indent_eq_sub = c("EQ_SUB", "EQ_FORMALS"), # TODO rename
220-
update_indention_ref_fun_dec = "FUNCTION"
220+
update_indention_reference_function_declaration = "FUNCTION"
221221
),
222222
line_breaks = list(
223223
set_line_break_before_curly_opening = "'{'",
224224
remove_line_break_before_round_closing_after_curly = "'}'",
225-
remove_line_breaks_in_fun_dec = "FUNCTION",
225+
remove_line_breaks_in_function_declaration = "FUNCTION",
226226
set_line_break_around_curly_curly = "'{'",
227227
style_line_break_around_curly = "'{'",
228228
add_line_break_after_pipe = c("SPECIAL-PIPE", "PIPE")
@@ -231,7 +231,7 @@ tidyverse_style <- function(scope = "tokens",
231231
resolve_semicolon = "';'",
232232
add_brackets_in_pipe = c("SPECIAL-PIPE", "PIPE"),
233233
force_assignment_op = "EQ_ASSIGN",
234-
wrap_if_else_while_for_fun_multi_line_in_curly = c(
234+
wrap_if_else_while_for_function_multi_line_in_curly = c(
235235
"IF", "WHILE", "FOR", "FUNCTION"
236236
)
237237
)

man/set_space_around_op.Rd renamed to man/set_space_around_operator.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/unindent_fun_dec.Rd renamed to man/unindent_function_declaration.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/update_indention_ref.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/wrap_if_else_while_for_fun_multi_line_in_curly.Rd renamed to man/wrap_if_else_while_for_function_multi_line_in_curly.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)