get_function_body: get the body of a function

Description Usage Arguments Details Value Examples

View source: R/internals.R

Description

body reformats the code (see Examples and Details).

Usage

1

Arguments

object

The function from which to extract the body.
Should have been sourced with keep.source = TRUE.

Details

If we want to check a function as it is coded in a file, we need to get the original thing as coded in the file, no optimized version. In sys.source and source, keep.source = FALSE seems to use body. So we have to do it all over after sourcing with keep.source = TRUE (in check_functions_in_file).

Value

[character(n)]
the function body's lines.

Examples

1
2
3
4
source(system.file("source", "R", "utils.R", package = "cleanr"))
require(checkmate)
cleanr:::get_function_body(set_cleanr_options)[3:6]
utils::capture.output(body(set_cleanr_options))[4:6]

cleanr documentation built on May 12, 2021, 1:07 a.m.