diff --git a/R/paren_body_linter.R b/R/paren_body_linter.R index a758507b2..75d0b9b16 100644 --- a/R/paren_body_linter.R +++ b/R/paren_body_linter.R @@ -38,13 +38,12 @@ paren_body_linter <- make_linter_from_xpath( or preceding-sibling::WHILE ) ] - /following-sibling::expr[1] | //forcond[ @line1 = following-sibling::expr/@line2 and OP-RIGHT-PAREN/@col1 = following-sibling::expr/@col1 - 1 ] - /following-sibling::expr + /OP-RIGHT-PAREN ", lint_message = "Put a space between a right parenthesis and a body expression.", type = "style" diff --git a/tests/testthat/test-paren_body_linter.R b/tests/testthat/test-paren_body_linter.R index e461ea1a3..476a7b5cc 100644 --- a/tests/testthat/test-paren_body_linter.R +++ b/tests/testthat/test-paren_body_linter.R @@ -1,4 +1,4 @@ -testthat::test_that("paren_body_linter returns correct lints", { +test_that("paren_body_linter returns correct lints", { linter <- paren_body_linter() lint_msg <- rex::rex("Put a space between a right parenthesis and a body expression.") @@ -26,14 +26,20 @@ testthat::test_that("paren_body_linter returns correct lints", { "function()test", list( line_number = 1L, - column_number = 11L, + column_number = 10L, type = "style", line = "function()test", - ranges = list(c(11L, 14L)) + ranges = list(c(10L, 10L)) ), linter ) + expect_lint( + "for (ii in 1:10)ii", + list(column_number = 16L, ranges = list(c(16L, 16L))), + linter + ) + # paren_body_linter does not lint when the function body is defined on a new line expect_lint("function()\n test", NULL, linter)