Skip to contents

Individual session check function that inspects the attached packages. Session checkers can produce errors, warnings, or messages if requested.

Usage

check_attached_packages(
  action = "warn",
  allow_attached_packages = NULL,
  action_on_pass = "none"
)

Arguments

action

Behavior to take if the status is not clean. Possible values are "error", "warn", "message", and "none". The default is action = "warn".

allow_attached_packages

Character vector containing names of packages that are "allowed", and will not trigger an action if attached to the search path. The default is allow_attached_packages = NULL, in which case only base-priority packages are allowed.

action_on_pass

Behavior to take if the status is clean. Possible values are "message" and "none". The default is action_on_pass = "none".

Value

Invisibly returns an object of class sessioncheck_status.

Details

This checker inspects the list of packages that have been attached to the search path (e.g., via library()). Regardless of the value of allow_attached_packages, R packages that have "base" priority (e.g., base, utils, and grDevices) do not trigger an action. When allow_attached_packages = NULL these are the only packages that will not trigger actions.

Examples

check_attached_packages(action = "message")
#>  Unexpected packages: sessioncheck

# a session with no unexpected packages attached: `action` only controls
# what happens when a problem *is* found, so use `action_on_pass = "message"`
# to confirm the clean result instead
check_attached_packages(
  action = "none",
  allow_attached_packages = .packages(),
  action_on_pass = "message"
)
#>  No unexpected packages attached