Based on this Q&A , this code defines a package containing an active binding to the value 1. It passes devtools::check()
:
my_function <- function() 1
#' return 1
#' @usage my_active_binding
#' @name my_active_binding
NULL
.onLoad <- function(libname, pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding", my_function, env = ns)
namespaceExport(ns, "my_active_binding")
}
However if my active binding fails by default (in my use case it should be used in a specific context),
then devtools::check()
is not happy anymore.
Edit: actually if I use print()
or message()
rather than stop()
I run into the same issues
my_function <- function() stop("stop!!!")
#' stop!!!
#' @usage my_active_binding
#' @name my_active_binding
NULL
.onLoad <- function(libname, pkgname) {
ns <- asNamespace(pkgname)
makeActiveBinding("my_active_binding", my_function, env = ns)
namespaceExport(ns, "my_active_binding")
}
See below :
-- R CMD check results ---------------------------------- abtest 0.0.0.9000 ----
Duration: 21s
> checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
GPL3
Standardizable: FALSE
> checking S3 generic/method consistency ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> -> Filter -> unlist -> lapply -> FUN -> <Anonymous>
Ex�cution arr�t�e
See section 'Generic functions and methods' in the 'Writing R
Extensions' manual.
> checking for code/documentation mismatches ... WARNING
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
> checking dependencies in R code ... NOTE
Error in (function () : stop!!!
Ex�cution arr�t�e
> checking foreign function calls ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
See chapter 'System and foreign language interfaces' in the 'Writing R
Extensions' manual.
> checking R code for possible problems ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... withCallingHandlers -> do.call -> <Anonymous> -> get -> <Anonymous>
Ex�cution arr�t�e
> checking Rd \usage sections ... NOTE
Error in (function () : stop!!!
Calls: <Anonymous> ... Filter -> unlist -> lapply -> FUN -> get -> <Anonymous>
Ex�cution arr�t�e
The \usage entries for S3 methods should use the \method markup and not
their full name.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
0 errors v | 3 warnings x | 4 notes x
Erreur : R CMD check found WARNINGs
Ex�cution arr�t�e
Exited with status 1.
How can I do to integrate this active binding in my package and satisfy devtools::check()
/ R CMD check ?