Skip to content

Commit 7586501

Browse files
don't move comments a line down since they can be qa comments
1 parent 08a3850 commit 7586501

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

R/rules-line-breaks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ style_line_break_around_curly <- function(strict, pd) {
157157
to_break <- lag(opening_before, default = FALSE) | closing_before
158158
len_to_break <- sum(to_break)
159159
pd$lag_newlines[to_break] <- ifelse(rep(strict, len_to_break),
160-
1L,
160+
ifelse(pd$token[to_break] == "COMMENT", pmin(1L, pd$lag_newlines[to_break]), 1L),
161161
pmax(1L, pd$lag_newlines[to_break])
162162
)
163163
} else {

tests/testthat/indention_multiple/overall-out.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ a <- function(x) {
88
22 + 1
99
))
1010
if (x > 10) {
11-
for (x in 22) {
12-
# FIXME in operator only to be surrounded by one space. What about %in%?
11+
for (x in 22) { # FIXME in operator only to be surrounded by one space. What about %in%?
1312
prin(x)
1413
}
1514
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
X_and_F_symbol_linter <- function() { # nolint: object_name.
2+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
X_and_F_symbol_linter <- function() { # nolint: object_name.
2+
}

tests/testthat/test-line_breaks_and_other.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ test_that("line is correctly broken around = ", {
6868
transformer = style_text
6969
), NA)
7070
})
71+
72+
test_that("comments are not moved down after {", {
73+
expect_warning(test_collection("line_breaks_and_other", "comment-around-curly",
74+
transformer = style_text
75+
), NA)
76+
})

0 commit comments

Comments
 (0)