3333# ' transformers <- tidyverse_style()
3434# ' pd_nested <- styler:::compute_parse_data_nested(c(
3535# ' "call(",
36- # ' " ab = 1 ,",
36+ # ' " ab = 1L ,",
3737# ' " a = 2",
3838# ' ")"
3939# ' )) %>%
@@ -50,7 +50,7 @@ token_is_on_aligned_line <- function(pd_flat) {
5050 pd_flat $ .lag_spaces <- lag(pd_flat $ spaces )
5151 pd_by_line <- split(pd_flat , line_idx )
5252 pd_by_line [purrr :: map_lgl(pd_by_line , ~ any(.x $ stylerignore ))] <- NULL
53- if (length(pd_by_line ) < 1 ) {
53+ if (length(pd_by_line ) < 1L ) {
5454 return (TRUE )
5555 }
5656 last_line_is_closing_brace_only <- nrow(last(pd_by_line )) == 1
@@ -93,7 +93,7 @@ token_is_on_aligned_line <- function(pd_flat) {
9393 }
9494
9595 pd_by_line <- alignment_drop_comments(pd_by_line )
96- if (length(pd_by_line ) < 1 ) {
96+ if (length(pd_by_line ) < 1L ) {
9797 return (TRUE )
9898 }
9999 pd_by_line <- alignment_drop_last_expr(pd_by_line ) %> %
@@ -104,10 +104,9 @@ token_is_on_aligned_line <- function(pd_flat) {
104104 # now, pd only contains arguments separated by values, ideal for iterating
105105 # over columns.
106106 n_cols <- map_int(pd_by_line , ~ sum(.x $ token == " ','" ))
107- previous_line <- 0
108- current_col <- 0
109- start_eval <- ifelse(alignment_col1_all_named(pd_by_line ), 1 , 2 )
110- for (column in seq2(1 , max(n_cols ))) {
107+ previous_line <- current_col <- 0L
108+ start_eval <- ifelse(alignment_col1_all_named(pd_by_line ), 1L , 2L )
109+ for (column in seq2(1L , max(n_cols ))) {
111110 by_line <- alignment_serialize_column(pd_by_line , column ) %> %
112111 compact() %> %
113112 unlist() %> %
@@ -120,7 +119,7 @@ token_is_on_aligned_line <- function(pd_flat) {
120119 current_col <- nchar(by_line ) - as.integer(column > 1 )
121120 # Problem `by_line` counting from comma before column 3, previous_line
122121 # counting 1 space before ~
123- if (column > 1 ) {
122+ if (column > 1L ) {
124123 previous_line <- previous_line [
125124 intersect(names(previous_line ), names(by_line ))
126125 ]
@@ -129,28 +128,28 @@ token_is_on_aligned_line <- function(pd_flat) {
129128 }
130129
131130 is_aligned <- length(unique(current_col )) == 1L
132- if (! is_aligned || length(current_col ) < 2 ) {
131+ if (! is_aligned || length(current_col ) < 2L ) {
133132 # check 2: left aligned after , (comma to next token)
134133 current_col <- " ^(,[\\ s\\ t]*)[^ ]*.*$" %> %
135134 gsub(" \\ 1" , by_line , perl = TRUE ) %> %
136135 nchar() %> %
137136 magrittr :: subtract(1 )
138137
139- if (column > 1 ) {
138+ if (column > 1L ) {
140139 # must add previous columns, as first column might not align
141140 current_col <- previous_line + current_col
142141 }
143- if (length(current_col ) > 1 ) {
142+ if (length(current_col ) > 1L ) {
144143 is_aligned <- length(unique(current_col )) == 1L
145144 } else {
146- is_aligned <- current_col - max_previous_col == 1
145+ is_aligned <- current_col - max_previous_col == 1L
147146 current_col <- max_previous_col + current_col
148147 }
149148
150149 if (is_aligned ) {
151150 # if left aligned after ,
152- start_eval <- 2
153- previous_line <- nchar(by_line ) - 1 + previous_line # comma to comma
151+ start_eval <- 2L
152+ previous_line <- nchar(by_line ) - 1L + previous_line # comma to comma
154153 }
155154 } else {
156155 previous_line <- current_col
@@ -162,22 +161,22 @@ token_is_on_aligned_line <- function(pd_flat) {
162161 # match left aligned after =
163162 start_after_eq <- regexpr(" = [^ ]" , by_line )
164163 names(start_after_eq ) <- names(by_line )
165- start_after_eq <- start_after_eq [start_after_eq > 0 ]
164+ start_after_eq <- start_after_eq [start_after_eq > 0L ]
166165
167166 if (column > = start_eval ) {
168- if (length(start_after_eq ) == 0 ) {
167+ if (length(start_after_eq ) == 0L ) {
169168 return (FALSE )
170169 }
171170 # when match via , unsuccessful, matching by = must yield at least one =
172- if (column == 1 ) {
171+ if (column == 1L ) {
173172 current_col <- start_after_eq
174173 } else {
175174 current_col <- start_after_eq +
176175 previous_line [intersect(names(previous_line ), names(start_after_eq ))]
177176 }
178177 is_aligned <- all(
179- length(unique(current_col )) == 1 ,
180- length(start_after_eq ) > 1
178+ length(unique(current_col )) == 1L ,
179+ length(start_after_eq ) > 1L
181180 )
182181 if (! is_aligned ) {
183182 return (FALSE )
0 commit comments