print.checkglobalsg {checkglobals}R Documentation

Print "checkglobalsg" object

Description

Print method for S3-objects of class "checkglobalsg" characteristic to the "globals" list element of "checkglobals" objects returned by checkglobals, check_pkg or check_source.

Usage

## S3 method for class 'checkglobalsg'
print(x, format = "basic", pattern, ...)

Arguments

x

object inheriting from class "checkglobalsg".

format

character, one of the following two choices:

  • "basic", (default) prints only the name and source code location of the detected globals.

  • "detail", prints the name and location of the detected globals, as well as the lines in the source code file comprising the detected globals. The maximum number of lines printed per source code reference can be specified using maxLines.

pattern

an optional regular expression. Only names matching pattern are returned. glob2rx can be used to convert wildcard patterns to regular expressions.

...

additional arguments to configure the printed output. The following arguments can be specified:

  • all.names, a logical value. If TRUE, all object names are returned. If FALSE, names which begin with a ‘⁠.⁠’ are omitted. Defaults to TRUE.

  • maxRef, the maximum number of printed source code references per detected global/import. Defaults to 1.

  • maxLines, the maximum number of printed lines per source code reference, only used if format = "detail". Defaults to 5.

  • use_cli, a logical value indicating if cli should be used to format the printed output. Defaults to TRUE, which means that cli-formatting is attempted if cli is installed.

  • maxWidth, the maximum column width of the printed output. If cli is installed, the default width is determined by cli::console_width(). If cli is not installed, getOption("width") is checked. If getOption("width") is undefined, the column width defaults to 80.

Value

Returns the object x invisibly (via invisible)

Examples

## R-package from folder
chk <- checkglobals(
  pkg = system.file(
    "unit_tests", "pkg", "testpkg",
    package = "checkglobals"
  )
)
chk$globals

## print globals with references to source code
print(chk$globals, format = "detail", maxRef = 99)

## print without cli-formatting
print(chk$globals, use_cli = FALSE)

[Package checkglobals version 0.1.0 Index]