download_file_linter: Recommend usage of a portable 'mode' value for downloading...

View source: R/download_file_linter.R

download_file_linterR Documentation

Recommend usage of a portable mode value for downloading files

Description

mode = "w" (the default) or mode = "a" in download.file() can generate broken files on Windows. Instead, utils::download.file() recommends the usage of mode = "wb" and mode = "ab". If method = "curl" or method = "wget", no mode should be provided as it will be ignored.

Usage

download_file_linter()

Tags

best_practices, common_mistakes, robustness

See Also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "download.file(x = my_url)",
  linters = download_file_linter()
)

lint(
  text = "download.file(x = my_url, mode = 'w')",
  linters = download_file_linter()
)

lint(
  text = "download.file(x = my_url, method = 'curl', mode = 'wb')",
  linters = download_file_linter()
)

# okay
lint(
  text = "download.file(x = my_url, mode = 'wb')",
  linters = download_file_linter()
)

lint(
  text = "download.file(x = my_url, method = 'curl')",
  linters = download_file_linter()
)


lintr documentation built on Nov. 27, 2025, 9:06 a.m.