Skip to content

Commit

Permalink
Do not error with inline \\Sexpr.
Browse files Browse the repository at this point in the history
Fixes #127
  • Loading branch information
jimhester committed Nov 10, 2016
1 parent 72f1985 commit 7fe7e90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# lintr 1.0.0.9000 #
* Do not error with inline \\Sexpr (#127).
* Do not error with '<% %>' constructs (#185).
* Allow closing parenthesis or comma after closing curly brace (#167, @Enchufa2)
* Support checkstyle XML output (#156, @joshkgold)
Expand Down
5 changes: 5 additions & 0 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ extract_r_source <- function(filename, lines) {
starts <- grep(pattern$chunk.begin, lines, perl = TRUE)
ends <- grep(pattern$chunk.end, lines, perl = TRUE)

# no chunks found, so just return the lines
if (length(starts) == 0 || length(ends) == 0) {
return(lines)
}

if (length(starts) != length(ends)) {
stop("Malformed file!", call. = FALSE)
}
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-knitr_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ test_that("it does _not_ handle brew", {
),
default_linters)
})

test_that("it does _not_ error with inline \\Sexpr", {
expect_lint("#' text \\Sexpr{1 + 1} more text\n",
checks = list(
rex("Trailing blank lines are superfluous.")
),
default_linters)
})

0 comments on commit 7fe7e90

Please sign in to comment.