Skip to contents

Check that no absolute paths are used (e.g. "/var", "C:\System", "~/docs").

Usage

absolute_path_linter(lax = TRUE)

Arguments

lax

Less stringent linting, leading to fewer false positives. If TRUE, only lint path strings, which

  • contain at least two path elements, with one having at least two characters and

  • contain only alphanumeric chars (including UTF-8), spaces, and win32-allowed punctuation

See also

Examples

# will produce lints
lint(
  text = 'R"--[/blah/file.txt]--"',
  linters = absolute_path_linter()
)
#> <text>:1:2: warning: [absolute_path_linter] Do not use absolute paths.
#> R"--[/blah/file.txt]--"
#>  ^~~~~~~~~~~~~~~~~~~~~

# okay
lint(
  text = 'R"(./blah)"',
  linters = absolute_path_linter()
)
#>  No lints found.