Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, t
style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports.R", "R/cpp11.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0)
style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L)
tidyverse_math_token_spacing()
tidyverse_reindention()
tidyverse_style(scope = "tokens", strict = TRUE, indent_by = 2, start_comments_with_one_space = FALSE, reindention = tidyverse_reindention(), math_token_spacing = tidyverse_math_token_spacing())
Expand Down
4 changes: 2 additions & 2 deletions R/detect-alignment-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ alignment_has_correct_spacing_around_comma <- function(pd_sub) {
return(TRUE)
}
relevant_comma_token <- comma_tokens[seq2(1, length(comma_tokens) - 1L)]
correct_spaces_before <- pd_sub$.lag_spaces[relevant_comma_token] == 0
correct_spaces_after <- pd_sub$spaces[relevant_comma_token] > 0
correct_spaces_before <- pd_sub$.lag_spaces[relevant_comma_token] == 0L
correct_spaces_after <- pd_sub$spaces[relevant_comma_token] > 0L
all(correct_spaces_before) && all(correct_spaces_after)
}

Expand Down
2 changes: 1 addition & 1 deletion R/expr-is.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ is_asymmetric_tilde_expr <- function(pd) {

#' @rdname is_tilde_expr
is_symmetric_tilde_expr <- function(pd) {
is_tilde_expr(pd, tilde_pos = 2)
is_tilde_expr(pd, tilde_pos = 2L)
}

is_subset_expr <- function(pd) {
Expand Down
6 changes: 3 additions & 3 deletions R/indent.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ indent_without_paren_if_else <- function(pd, indent_by) {
}
needs_indention_now <- pd$lag_newlines[
next_non_comment(pd, which(pd$token == "')'"))
] > 0
] > 0L

if (needs_indention_now) {
pd$indent[expr_after_if] <- indent_by
Expand All @@ -57,7 +57,7 @@ indent_without_paren_if_else <- function(pd, indent_by) {

needs_indention_now <- pd$lag_newlines[
next_non_comment(pd, which(pd$token == "ELSE"))
] > 0
] > 0L

if (has_else_without_curly_or_else_chid && needs_indention_now) {
pd$indent[seq(else_idx + 1, nrow(pd))] <- indent_by
Expand Down Expand Up @@ -214,7 +214,7 @@ set_multi_line <- function(pd) {
#' @param pd A parse table.
#' @keywords internal
pd_is_multi_line <- function(pd) {
pd_multi_line(pd) > 0
pd_multi_line(pd) > 0L
}

pd_multi_line <- function(pd) {
Expand Down
4 changes: 2 additions & 2 deletions R/rules-indention.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ indent_eq_sub <- function(pd,
if (!any(eq_sub)) {
return(pd)
}
has_line_break <- pd$lag_newlines > 0 | pd$token == "COMMENT"
has_line_break <- pd$lag_newlines > 0L | pd$token == "COMMENT"
indent_indices <- which(lag(eq_sub, default = FALSE) & has_line_break)
if (any(pd$token[indent_indices] == "COMMENT")) {
indent_indices <- purrr::map_int(indent_indices, function(idx) {
Expand All @@ -77,7 +77,7 @@ indent_eq_sub <- function(pd,
#' @describeIn update_indention Is used to indent for / while / if / if-else
#' statements that do not have curly parenthesis.
#' @keywords internal
indent_without_paren <- function(pd, indent_by = 2) {
indent_without_paren <- function(pd, indent_by = 2L) {
pd %>%
indent_without_paren_for_while_fun(indent_by) %>%
indent_without_paren_if_else(indent_by)
Expand Down
6 changes: 3 additions & 3 deletions R/rules-tokens.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_brackets_in_pipe_one <- function(pd, pos) {
rh_child <- pd$child[[next_non_comment]]
if (nrow(rh_child) < 2 && rh_child$token == "SYMBOL") {
child <- pd$child[[next_non_comment]]
new_pos_ids <- create_pos_ids(child, 1, after = TRUE, n = 2)
new_pos_ids <- create_pos_ids(child, 1, after = TRUE, n = 2L)
new_pd <- create_tokens(
texts = c("(", ")"),
lag_newlines = rep(0L, 2),
Expand Down Expand Up @@ -68,7 +68,7 @@ add_brackets_in_pipe_one <- function(pd, pos) {
#' braces. Used for unindention.
#' @keywords internal
#' @importFrom purrr when
wrap_if_else_while_for_fun_multi_line_in_curly <- function(pd, indent_by = 2) {
wrap_if_else_while_for_fun_multi_line_in_curly <- function(pd, indent_by = 2L) {
key_token <- when(
pd,
is_cond_expr(.) ~ "')'",
Expand Down Expand Up @@ -127,7 +127,7 @@ wrap_multiline_curly <- function(pd, indent_by, key_token, space_after = 1L) {
#' already wrapped into a such.
#' @inheritParams wrap_multiline_curly
#' @keywords internal
wrap_else_multiline_curly <- function(pd, indent_by = 2, space_after = 0) {
wrap_else_multiline_curly <- function(pd, indent_by = 2, space_after = 0L) {
if (contains_else_expr(pd) &&
pd_is_multi_line(pd) &&
contains_else_expr_that_needs_braces(pd) &&
Expand Down
6 changes: 3 additions & 3 deletions R/stylerignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ add_stylerignore <- function(pd_flat) {
if (!env_current$any_stylerignore) {
return(pd_flat)
}
pd_flat_lat_line1 <- lag(pd_flat$line2, default = 0)
pd_flat_lat_line1 <- lag(pd_flat$line2, default = 0L)
on_same_line <- pd_flat$line1 == pd_flat_lat_line1
cumsum_start <- cumsum(start_candidate & !on_same_line)
cumsum_stop <- cumsum(
grepl(option_read("styler.ignore_stop"), parse_text) &
pd_flat$token == "COMMENT"
)
pd_flat$indicator_off <- cumsum_start + cumsum_stop
is_invalid <- cumsum_start - cumsum_stop < 0 | cumsum_start - cumsum_stop > 1
is_invalid <- cumsum_start - cumsum_stop < 0L | cumsum_start - cumsum_stop > 1L
if (any(is_invalid)) {
warn(paste0(
"Invalid stylerignore sequences found, potentially ignoring some of the ",
"markers set.\nSee `help(\"stylerignore\", \"styler\")`."
))
}

to_ignore <- as.logical(pd_flat$indicator_off %% 2)
to_ignore <- as.logical(pd_flat$indicator_off %% 2L)
to_ignore[is_invalid] <- FALSE
single_lines_to_ignore <- pd_flat$line1[start_candidate & on_same_line]
to_ignore[pd_flat$line1 %in% single_lines_to_ignore] <- TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/testing-mocks.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' [compute_indent_indices()], we must have
#' a way of testing this without the interaction of `\{\{`.
#' @examples
#' styler:::style_text_without_curly_curly("rlang::list2({{ x }} := 2)")
#' styler:::style_text_without_curly_curly("rlang::list2({{ x }} := 2L)")
#' styler:::style_text("rlang::list2({{ x }} := 3)")
#' @keywords internal
#' @seealso set_line_break_around_curly_curly
Expand Down
4 changes: 2 additions & 2 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ NULL
#' transformations but remove EOL spaces and indention due to the way the
#' serialization is set up.
#' @keywords internal
style_empty <- function(text, base_indention = 0) {
style_empty <- function(text, base_indention = 0L) {
transformers <- list(
# transformer functions
initialize = default_style_guide_attributes,
Expand Down Expand Up @@ -350,7 +350,7 @@ local_test_setup <- function(cache = FALSE,
}

cache_more_specs_default <- function() {
cache_more_specs(include_roxygen_examples = TRUE, base_indention = 0)
cache_more_specs(include_roxygen_examples = TRUE, base_indention = 0L)
}

#' Test `transformers_drop` for consistency
Expand Down
2 changes: 1 addition & 1 deletion R/transform-block.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ parse_transform_serialize_r_block <- function(pd_nested,
target_indention = transformers$reindention$indention,
comments_only = transformers$reindention$comments_only
)
is_on_newline <- flattened_pd$lag_newlines > 0
is_on_newline <- flattened_pd$lag_newlines > 0L
is_on_newline[1] <- TRUE
flattened_pd$lag_spaces[is_on_newline] <- flattened_pd$lag_spaces[is_on_newline] + base_indention
serialized_transformed_text <- serialize_parse_data_flattened(
Expand Down
2 changes: 1 addition & 1 deletion R/transform-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ identify_raw_chunks <- function(lines,
ends <- grep("^[\t >]*```+\\s*$", lines, perl = TRUE)
ends <- purrr::imap_int(starts, ~ ends[which(ends > .x)[1]]) %>%
stats::na.omit()
if (length(starts) != length(ends) || anyDuplicated(ends) != 0) {
if (length(starts) != length(ends) || anyDuplicated(ends) != 0L) {
abort("Malformed file!")
}
} else if (filetype == "Rnw") {
Expand Down
2 changes: 1 addition & 1 deletion R/transform-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ apply_transformers <- function(pd_nested, transformers) {
pd_nested,
c(
transformers$initialize, transformers$line_break, set_multi_line,
if (length(transformers$line_break) != 0) update_newlines
if (length(transformers$line_break) != 0L) update_newlines
)
)

Expand Down
2 changes: 1 addition & 1 deletion R/ui-styling.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ style_text <- function(text,
style = tidyverse_style,
transformers = style(...),
include_roxygen_examples = TRUE,
base_indention = 0) {
base_indention = 0L) {
transformer <- make_transformer(transformers,
include_roxygen_examples = include_roxygen_examples,
base_indention = base_indention
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ odd_index <- function(x) {
if (length(x) < 1L) {
return(NULL)
}
seq(1L, length(x), by = 2)
seq(1L, length(x), by = 2L)
}

even_index <- function(x) {
seq(2L, length(x), by = 2)
seq(2L, length(x), by = 2L)
}

is_windows <- function() {
Expand Down
2 changes: 1 addition & 1 deletion man/style_text.Rd

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

2 changes: 1 addition & 1 deletion man/style_text_without_curly_curly.Rd

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

2 changes: 1 addition & 1 deletion man/test_transformer.Rd

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

2 changes: 1 addition & 1 deletion man/update_indention.Rd

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

2 changes: 1 addition & 1 deletion man/wrap_else_multiline_curly.Rd

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

2 changes: 1 addition & 1 deletion man/wrap_if_else_while_for_fun_multi_line_in_curly.Rd

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