Cast an S3-object of class "checkglobals" to SARIF json.
Usage
# S3 method for class 'checkglobals'
as_sarif_json(x, path, pattern, which = c("global", "import"), ...)Arguments
- x
object inheriting from class
"checkglobals".- path
(optional) file path to write the SARIF json content. If missing, the SARIF content is returned as an object of class
json.- pattern
an optional regular expression. Only names matching
patternare returned.glob2rxcan be used to convert wildcard patterns to regular expressions.- which
a character vector, either
"global"to print all unrecognized global variables,"import"to print all detected imported functions and variables, or both (default).- ...
additional arguments to configure the output:
all.names, a logical value. IfTRUE, all object names are returned. IfFALSE, names which begin with a . are omitted. Defaults toTRUE.pretty, a logical value passed tojsonlite::toJSON. Defaults toFALSE.root_dir, directory to use as root relative to which all result uri's are generated.use_cli, a logical value indicating ifclishould be used to format the result messages. Defaults toTRUE, which means thatcli-formatting is attempted ifcliis installed.markdown, a logical value indicating ifmarkdownresult fields should be included. Defaults toFALSE.first_only, a logical value to include only the first detected location of an unknown global variable or function (instead of all detected locations). Defaults toFALSE.
Value
if path is provided writes the SARIF json content to path and
returns the path invisibly, otherwise returns the SARIF json content as a json object..
Examples
## R-package from folder
chk <- checkglobals(
pkg = system.file(
"unit_tests", "pkg", "testpkg",
package = "checkglobals"
)
)
json <- as_sarif_json(chk, pretty = TRUE, markdown = TRUE)