assert_no_globals: Assert that a function contains no global variables

View source: R/assert_no_globals.R

assert_no_globalsR Documentation

Assert that a function contains no global variables

Description

This function will stop code execution with an error if the function passed in uses a global variable.

Usage

assert_no_globals(test_function, name = deparse1(substitute(test_function)))

Arguments

test_function

function to check for global variables

name

(optional) the name of function as a string – passed to the error message

Value

nothing

Examples

## Not run: 
broken_function <- function() print(y)
assert_no_globals(broken_function)
assert_no_globals(broken_function, name = "the_name_of_my_function")

## End(Not run)


IBAHCM/RPiR documentation built on Jan. 12, 2023, 7:41 p.m.