Skip to contents

system.file() has a ... argument which, internally, is passed to file.path(), so including it in user code is repetitive.

Usage

system_file_linter()

See also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = 'system.file(file.path("path", "to", "data"), package = "foo")',
  linters = system_file_linter()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[system_file_linter] Use the `...` argument of system.file() to expand paths, e.g. system.file("data", "model.csv", package = "myrf") instead of system.file(file.path("data", "model.csv"), package = "myrf")

lint(
  text = 'file.path(system.file(package = "foo"), "path", "to", "data")',
  linters = system_file_linter()
)
#> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[system_file_linter] Use the `...` argument of system.file() to expand paths, e.g. system.file("data", "model.csv", package = "myrf") instead of file.path(system.file(package = "myrf"), "data", "model.csv")

# okay
lint(
  text = 'system.file("path", "to", "data", package = "foo")',
  linters = system_file_linter()
)