Skip to content

Commit

Permalink
Do not treat Rmd files without code as being all code
Browse files Browse the repository at this point in the history
Fixes #370
  • Loading branch information
jimhester committed Sep 27, 2019
1 parent a75a75c commit d449090
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 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.3.9000 #
* R Markdown files that do not contain chunks are no longer treated as code (#370).
* `open_curly_linter()` and `closed_curly_linter()` now do not lint double curly syntax (#388)
* `open_curly_linter()` now allows comments after the curly braces (#188)
* `lint_package()` now excludes `R/RcppExports.R` by default (#282)
Expand Down
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extract_r_source <- function(filename, lines) {

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

if (length(starts) != length(ends)) {
Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-knitr_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ test_that("it does _not_ handle brew", {
})

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.")
),
expect_lint("#' text \\Sexpr{1 + 1} more text",
NULL,
default_linters)
})

0 comments on commit d449090

Please sign in to comment.