Parse R source code and identify calls to selected functions that are missing required named arguments.

lintFunctionArgs_file(filePath = NULL, rules = NULL, fullPath = FALSE)

lintFunctionArgs_dir(dirPath = "./R", rules = NULL, fullPath = FALSE)

Arguments

filePath

Path to a single R source file.

rules

Named list of linting rules. Each list name is a function name and each value is a character vector of required named arguments.

fullPath

Logical specifying whether returned file paths should be absolute paths. If FALSE, only base file names are returned.

dirPath

Path to a directory containing R source files.

Value

A tibble describing matching function calls, with columns:

file

Source file path or file name.

line_number

Line number where the function call begins.

column_number

Column number where the function call begins.

function_name

Name of the function being checked.

named_args

List column containing named arguments used in the call.

includes_required

Logical indicating whether all required named arguments were supplied.

Details

Rules are supplied as a named list where each name is a function to check and each value is a character vector of required argument names. A function call passes when all required arguments are supplied by name.

This linter only checks whether arguments are named in the call. It does not evaluate code, inspect argument values, or detect unnamed positional arguments.

Limitations

This linter only detects named arguments. For example, foo(x = bar, "baz") is treated as specifying the named argument x, but the value bar and the unnamed argument "baz" are not inspected.

Examples

if (FALSE) { # \dontrun{
rules <- list(
  fn_one = "x",
  fn_two = c("foo", "bar")
)

lintFunctionArgs_file(
  filePath = "local_test/timezone_lint_test_script.R",
  rules = rules
)

lintFunctionArgs_dir(
  dirPath = "./R",
  rules = MazamaCoreUtils::timezoneLintRules
)
} # }