Lists of function names and operators for undesirable_function_linter()
and undesirable_operator_linter()
.
There is a list for the default elements and another that contains all available elements.
Use modify_defaults()
to produce a custom list.
Usage
all_undesirable_functions
default_undesirable_functions
all_undesirable_operators
default_undesirable_operators
Details
The following functions are sometimes regarded as undesirable:
.libPaths()
As an alternative, usewithr::with_libpaths()
for a temporary change instead of permanently modifying the library location.attach()
As an alternative, use roxygen2's @importFrom statement in packages, or::
in scripts.attach()
modifies the global search path.browser()
As an alternative, remove this likely leftover from debugging. It pauses execution when run.debug()
As an alternative, remove this likely leftover from debugging. It traps a function and causes execution to pause when that function is run.debugcall()
As an alternative, remove this likely leftover from debugging. It traps a function and causes execution to pause when that function is run.debugonce()
As an alternative, remove this likely leftover from debugging. It traps a function and causes execution to pause when that function is run.detach()
As an alternative, avoid modifying the global search path. Detaching environments from the search path is rarely necessary in production code.library()
As an alternative, use roxygen2's @importFrom statement in packages and::
in scripts, instead of modifying the global search path.mapply()
As an alternative, useMap()
to guarantee a list is returned and simplify accordingly.options()
As an alternative, usewithr::with_options()
for a temporary change instead of permanently modifying the session options.par()
As an alternative, usewithr::with_par()
for a temporary change instead of permanently modifying the graphics device parameters.require()
As an alternative, use roxygen2's @importFrom statement in packages andlibrary()
or::
in scripts, instead of modifying the global search path.sapply()
As an alternative, usevapply()
with an appropriateFUN.VALUE=
argument to obtain type-stable simplification.setwd()
As an alternative, usewithr::with_dir()
for a temporary change instead of modifying the global working directory.sink()
As an alternative, usewithr::with_sink()
for a temporary redirection instead of permanently redirecting output.source()
As an alternative, manage dependencies through packages.source()
loads code into the global environment unlesslocal = TRUE
is used, which can cause hard-to-predict behavior.structure()
As an alternative, Useclass<-
,names<-
, andattr<-
to set attributes.Sys.setenv()
As an alternative, usewithr::with_envvar()
for a temporary change instead of permanently modifying global environment variables.Sys.setlocale()
As an alternative, usewithr::with_locale()
for a temporary change instead of permanently modifying the session locale.trace()
As an alternative, remove this likely leftover from debugging. It traps a function and causes execution of arbitrary code when that function is run.undebug()
As an alternative, remove this likely leftover from debugging. It is only useful for interactive debugging withdebug()
.untrace()
As an alternative, remove this likely leftover from debugging. It is only useful for interactive debugging withtrace()
.
The following operators are sometimes regarded as undesirable:
<<-
. It assigns outside the current environment in a way that can be hard to reason about. Prefer fully-encapsulated functions wherever possible, or, if necessary, assign to a specific environment withassign()
. Recall that you can create an environment at the desired scope withnew.env()
.:::
. It accesses non-exported functions inside packages. Code relying on these is likely to break in future versions of the package because the functions are not part of the public interface and may be changed or removed by the maintainers without notice. Use public functions via::
instead.<<-
. It assigns outside the current environment in a way that can be hard to reason about. Prefer fully-encapsulated functions wherever possible, or, if necessary, assign to a specific environment withassign()
. Recall that you can create an environment at the desired scope withnew.env()
.