-
Notifications
You must be signed in to change notification settings - Fork 188
Support case where specified method ignores mode in download_linter() #2883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,13 @@ test_that("download_file_linter skips allowed usages", { | |
# 'w' or 'a' but passed to different arguments | ||
expect_no_lint("download.file(x, destfile = 'w', mode = 'wb')", linter) | ||
expect_no_lint("download.file(x, mode = 'wb', method = 'internal', quiet = TRUE, 'w')", linter) | ||
|
||
# if mode = "wget" or "curl", mode is ignored so we don't lint on the default | ||
expect_no_lint("download.file(x, method = 'curl')", linter) | ||
expect_no_lint("download.file(x, method = 'wget')", linter) | ||
|
||
expect_no_lint("download.file(x, method = 'internal', mode = 'wb')", linter) | ||
expect_no_lint("download.file(x, method = method, mode = 'wb')", linter) | ||
}) | ||
|
||
test_that("download_file_linter blocks simple disallowed usages", { | ||
|
@@ -15,21 +22,29 @@ test_that("download_file_linter blocks simple disallowed usages", { | |
|
||
# Case 1: implicit default (mode = "w") | ||
expect_lint("download.file(x)", lint_message, linter) | ||
expect_lint("download.file(x, method = 'internal')", lint_message, linter) | ||
|
||
# Case 2: non-portable mode specified by name | ||
expect_lint("download.file(x, mode = 'w')", lint_message, linter) | ||
expect_lint("download.file(x, mode = 'a')", lint_message, linter) | ||
expect_lint("download.file(x, method = method, mode = 'w')", lint_message, linter) | ||
|
||
# 'wb' passed to different argument | ||
expect_lint("download.file(x, mode = 'w', method = 'internal', quiet = TRUE, 'wb')", lint_message, linter) | ||
expect_lint("download.file(cacheOK = TRUE, destfile, method, quiet, x = 'wb')", lint_message, linter) | ||
|
||
# mode explicitly specified with a method that ignores it | ||
lint_message <- rex::rex("mode argument value is ignored") | ||
expect_lint("download.file(x, method = 'wget', mode = 'w')", lint_message, linter) | ||
expect_lint("download.file(x, method = 'curl', mode = 'wb')", lint_message, linter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a test where |
||
}) | ||
|
||
test_that("lints vectorize", { | ||
expect_lint( | ||
trim_some("{ | ||
download.file(x, mode = 'w') | ||
download.file(y, mode = 'a') | ||
download.file(z, mode = 'wb', method = 'curl') | ||
}"), | ||
list( | ||
list( | ||
|
@@ -39,6 +54,10 @@ test_that("lints vectorize", { | |
list( | ||
rex::rex("download.file() should use mode = 'ab'"), | ||
line_number = 3L | ||
), | ||
list( | ||
rex::rex("mode argument value is ignored"), | ||
line_number = 4L | ||
) | ||
), | ||
download_file_linter() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include a corresponding example?