From ab6cb648791050ce6792285c6cb6fd4acba762e2 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 30 Nov 2024 23:14:48 +0100 Subject: [PATCH] address feedback --- R/rules-line-breaks.R | 9 ++------- R/style-guides.R | 4 ++-- tests/testthat/test-transformers-drop.R | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 4ae18b760..d1c4458f5 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -449,12 +449,7 @@ remove_empty_lines_after_opening_and_before_closing_braces <- function(pd) { } -reduce_extra_blank_lines_between_scopes <- function(pd, allowed_blank_lines = 2L) { - # Calculate the maximum allowed lag_newlines - max_lag_newlines <- allowed_blank_lines + 1L # +1 accounts for the line with the previous token - - # cap lag_newlines at max_lag_newlines - pd$lag_newlines <- pmin(pd$lag_newlines, max_lag_newlines) - +reduce_extra_blank_lines_between_top_level_exprs <- function(pd, allowed_blank_lines = 2L) { + pd$lag_newlines <- pmin(pd$lag_newlines, allowed_blank_lines + 1L) pd } diff --git a/R/style-guides.R b/R/style-guides.R index b1fad6bc7..f73fe8a0e 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -139,8 +139,8 @@ tidyverse_style <- function(scope = "tokens", if (strict) remove_line_break_before_round_closing_after_curly, remove_line_breaks_in_fun_dec = if (strict) remove_line_breaks_in_fun_dec, - reduce_extra_blank_lines_between_scopes = - if (strict) reduce_extra_blank_lines_between_scopes, + reduce_extra_blank_lines_between_top_level_exprs = + if (strict) reduce_extra_blank_lines_between_top_level_exprs, style_line_break_around_curly = partial( style_line_break_around_curly, strict diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index 6d7dc099a..659baa18d 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -72,7 +72,7 @@ test_that("tidyverse transformers are correctly dropped", { names_line_break <- c( "remove_empty_lines_after_opening_and_before_closing_braces", - "reduce_extra_blank_lines_between_scopes", + "reduce_extra_blank_lines_between_top_level_exprs", "set_line_break_around_comma_and_or", "set_line_break_after_assignment", "set_line_break_after_opening_if_call_is_multi_line",