lintFunctionArgs {MazamaCoreUtils} | R Documentation |
Lint a source file's function arguments
Description
This function parses an R Script file, grouping function calls and the named arguments passed to those functions. Then, based on a set of rules, it is determined if functions of interest have specific named arguments specified.
Usage
lintFunctionArgs_file(filePath = NULL, rules = NULL, fullPath = FALSE)
lintFunctionArgs_dir(dirPath = "./R", rules = NULL, fullPath = FALSE)
Arguments
filePath |
Path to a file, given as a length one character vector. |
rules |
A named list where the name of each element is a function name, and the value is a character vector of the named argument to check for. All arguments must be specified for a function to "pass". |
fullPath |
Logical specifying whether to display absolute paths. |
dirPath |
Path to a directory, given as a length one character vector. |
Value
A tibble
detailing the results of the lint.
Linting Output
The output of the function argument linter is a tibble with the following columns:
- file_path
path to the source file
- line_number
Line of the source file the function is on
- column_number
Column of the source file the function starts at
- function_name
The name of the function
- named_args
A vector of the named arguments passed to the function
- includes_required
True iff the function specifies all of the named arguments required by the given rules
Limitations
This function is only able to test for named arguments passed to a function.
For example, it would report that foo(x = bar, "baz")
has specified
the named argument x
, but not that bar
was the value of the
argument, or that "baz"
had been passed as an unnamed argument.
Examples
## Not run:
library(MazamaCoreUtils)
# Example rule list for checking
exRules <- list(
"fn_one" = "x",
"fn_two" = c("foo", "bar")
)
# Example of using included timezone argument linter
lintFunctionArgs_file(
"local_test/timezone_lint_test_script.R",
MazamaCoreUtils::timezoneLintRules
)
## End(Not run)