r-lib / rex

Friendly regular expressions for R.
https://rex.r-lib.org
Other
333 stars 27 forks source link

"Note: possible error in 'or(...)'" during R CMD INSTALL #64

Open salim-b opened 3 years ago

salim-b commented 3 years ago

I use a simple

rex::rex(start, or("1st_string",
                   "2nd_string",
                   "3rd_string",
                   "4th_string"))

in an R package and followed the advice to call rex::register_shortcuts(pkg_name = "my_pkg") to avoid NOTEs by R CMD Check.

But when building the package, R CMD INSTALL prints a note like:

** byte-compile and prepare package for lazy loading
Note: possible error in 'or("1st_string", ': unused arguments ("3rd_string", "4th_string") at (...)

What's happening here?

When I wrap the strings in an additional c(), the note goes away. But rex:::or() takes a dots argument

> rex:::or
function (...) 
{
    group(regex(paste0(collapse = "|", unlist(escape_dots(...)))))
}
<bytecode: 0x56006a276840>
<environment: namespace:rex>

so why the complaint about unused arguments? (they're actually properly used, it's just R CMD INSTALL that complains...)

jimhester commented 3 years ago

Looks to me like a false positive from R CMD check, unfortunately there is not much we can do about it other than using your suggested workaround.