set_cleanr_options {cleanr}R Documentation

Set Options for cleanr

Description

A convenience function for options.

Usage

set_cleanr_options(..., reset = FALSE, overwrite = TRUE)

Arguments

...

See options. See function_checks and file_checks for options to be set with cleanr. Use get_cleanr_options to get the current values. cleanr's standard defaults are: ⁠ max_file_width=80 max_file_length=300 max_lines=65 max_lines_of_code=50 max_num_arguments=5 max_nesting_depth=3 max_line_width=80 check_return=TRUE ⁠

reset

[boolean(1)]
Reset all cleanr options to the package's defaults?

overwrite

[boolean(1)]
Overwrite options already set? Is set to FALSE on package loading to ensure your previously set cleanr options won't get overridden. Just ignore that argument.

Details

cleanr loads a couple of options as defaults for its functions. The defaults are stored in a list element of options. All checks (see function_checks and file_checks) can be disabled by setting the corresponding option list item to NULL or FALSE.

Value

Invisibly TRUE.

See Also

Other option wrappers: get_cleanr_options()

Examples

# R.C. Martin's Clean Code recommends monadic argument lists.
cleanr::set_cleanr_options(max_num_arguments = 1)
# R.C. Martin's Clean Code recommends functions less than 20 lines long.
cleanr::set_cleanr_options(max_lines = 30, max_lines_of_code = 20)
# same as above:
cleanr::set_cleanr_options(list(max_lines = 30, max_lines_of_code = 20))
cleanr::get_cleanr_options(flatten_list = TRUE)
# we delete all options and set some anew
options("cleanr" = NULL)
options("cleanr" = list(max_lines = 30, max_lines_of_code = 20))
# fill the missing options with the package's defaults:
cleanr::set_cleanr_options(overwrite = FALSE)
cleanr::get_cleanr_options(flatten_list = TRUE)
# reset to the package's defaults:
cleanr::set_cleanr_options(reset = TRUE)
cleanr::get_cleanr_options(flatten_list = TRUE)

[Package cleanr version 1.4.0 Index]