Check each method body in an object if it contains names that do not
explicitly bind to a specified namespace via ::
.
Source: R/utilities.R
check_method.Rd
Method body could contain names like "mutate" that are from packages,
it usually would not be a problem as long as the package namespace is in
the search path or it is available in the parent environment of the object.
However, if the package is not loaded via functions like library()
and
the name used in the method body is unavailable in the parent environment of
the object, then an error may be raised saying that "object name
not found"
when the method is run.
This function helps detect this kind of
problems. Users needs to specify the names they want to detect, and specify
the package they belong to.
Arguments
- env
Environment. An environment.
- symbol_name
Character. Names that want to be detected.
- target_namespace
Character. Name of the package that symbols belong to.
Examples
e <- new.env()
register_method(e, test = function() cli_alert_info("test"))
check_method(e, "cli_alert_info", "cli")
#> Found `cli_alert_info` in method `test`.
register_method(e, test = function() cli::cli_alert_info("test"))
check_method(e, "cli_alert_info", "cli")