You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an R source file which causes lintr to throw its hands in the air and fail with an error. The problem is in the extract_r_source function.
To reproduce:
lines <- c("# This single comment `r length(x)` with some inline code is enough.\n")
temp <- tempfile(fileext = '.R')
cat(lines, file = temp)
tryCatch(lint(temp, with_defaults()), finally = unlink(temp))
# Error in rep.int(NA_character_, max(ends - 1)) : invalid 'times' value
# In addition: Warning messages:
#1: In max(ends - 1) : no non-missing arguments to max; returning -Inf
#2: In rep.int(NA_character_, max(ends - 1)) :
# NAs introduced by coercion to integer range
If some knitr patterns are found but the chunk.end pattern doesn't end up matching any lines of code, an error is thrown by rep.int since -Inf gets passed as its times parameter. Leading up to the error:
pattern is not NULL.
ends and starts are integer(0) since no matching lines of code were found by grepl
calling max(integer(0) - 1) returns -Inf
rep.int(NA_character_, -Inf) throws the error above.
The text was updated successfully, but these errors were encountered:
I have an R source file which causes lintr to throw its hands in the air and fail with an error. The problem is in the
extract_r_source
function.To reproduce:
The error is from https://github.com/jimhester/lintr/blob/master/R/extract.R#L17.
If some knitr patterns are found but the
chunk.end
pattern doesn't end up matching any lines of code, an error is thrown byrep.int
since-Inf
gets passed as itstimes
parameter. Leading up to the error:pattern
is notNULL
.ends
andstarts
areinteger(0)
since no matching lines of code were found bygrepl
max(integer(0) - 1)
returns-Inf
rep.int(NA_character_, -Inf)
throws the error above.The text was updated successfully, but these errors were encountered: