check_method {bandicoot}R Documentation

Check each method body in an object if it contains names that do not explicitly bind to a specified namespace via ::.

Description

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.

Usage

check_method(env, symbol_name, target_namespace)

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.

Value

No return value, called for side effects.

Examples


e <- new.env()
register_method(e, test = function() cli_alert_info("test"))
check_method(e, "cli_alert_info", "cli")

register_method(e, test = function() cli::cli_alert_info("test"))
check_method(e, "cli_alert_info", "cli")


[Package bandicoot version 1.0.0 Index]