Skip to content
Open
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
3 changes: 1 addition & 2 deletions R/paren_body_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions tests/testthat/test-paren_body_linter.R
Original file line number Diff line number Diff line change
@@ -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.")

Expand Down Expand Up @@ -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)

Expand Down
Loading