ropensci-review-tools / srr

Software Review Roclets
https://docs.ropensci.org/srr/
Other
5 stars 2 forks source link

Parsing non R files in R folder #18

Closed christophsax closed 3 years ago

christophsax commented 3 years ago

I have a file sysdata.rda in my R folder (which I guess is fine, per here). Thus, I got an invalid multibyte character in parser error when roxygen2::parse_file() runs:

https://github.com/ropensci-review-tools/srr/blob/a0b285d9093095c67f22808e22e93e4f484b9034/R/report.R#L109

It is easy to fix by going for .R files only:

    flist <- list.files (file.path (path, "R"), pattern = "\\.[rR]$", full.names = TRUE)

It may make sense to be a bit more verbose in case something fails, e.g.,:

    blocks <- lapply (flist, function (i) try(roxygen2::parse_file (i)))
    failing <- flist[sapply(blocks, inherits, "try-error")]
    if (length(failing) > 0L) {
      stop("parsing problem in: ", paste(failing, collapse = ", "))
    }
mpadge commented 3 years ago

Would you like to PR that?

mpadge commented 3 years ago

Please make sure the regex pattern is like this:

    flist <- normalizePath (list.files (file.path (path, "R"),
                                        full.names = TRUE,
                                        pattern = "\\.(r|R|q|s|S)$"))

Those are all of the allowed suffixes - yep, including ".q", which exists in a few really old-school packages :astonished: