-
Notifications
You must be signed in to change notification settings - Fork 340
Make error from finding arguments in '...' in expect_condition (et al) more informative #2055
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
429eabf
b226799
ec92bbd
95354d4
e06c270
0072b66
7873bcc
795d205
6368905
887f508
2826eee
cdc7f3a
5af66e5
3ddadcb
6ca1ee7
86d7bc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| expect_error(stop("!"), regexp = 1) | ||
| Condition | ||
| Error in `expect_error()`: | ||
| ! `pattern` must be a single string, `NA`, or `NULL`, not the number 1. | ||
| ! `regexp` must be a single string, `NA`, or `NULL`, not the number 1. | ||
| Code | ||
| expect_error(stop("!"), class = 1) | ||
| Condition | ||
|
|
@@ -35,12 +35,35 @@ | |
| expect_condition(stop("Hi!"), foo = "bar") | ||
| Condition | ||
| Error in `expect_condition()`: | ||
| ! Can't specify `...` without `pattern`. | ||
| ! Can't supply `...` unless `regexp` is set. | ||
| * Unused arguments: `foo`. | ||
| i Did you mean to use `regexp` so `...` is passed to `grepl()`? | ||
| Code | ||
| expect_condition(stop("Hi!"), , , "bar") | ||
| Condition | ||
| Error in `expect_condition()`: | ||
| ! Can't supply `...` unless `regexp` is set. | ||
|
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. I'm not sure how actionable this is, OTOH, I think it's unlikely to arise organically anyway (this is very strange code). Not worth spending more time on it IMO. |
||
| * Unused arguments: `..1`. | ||
| i Did you mean to use `regexp` so `...` is passed to `grepl()`? | ||
| Code | ||
| expect_condition(stop("Hi!"), , , "bar", fixed = TRUE) | ||
| Condition | ||
| Error in `expect_condition()`: | ||
| ! Can't supply `...` unless `regexp` is set. | ||
| * Unused arguments: `..1` and `fixed`. | ||
| i Did you mean to use `regexp` so `...` is passed to `grepl()`? | ||
| Code | ||
| expect_condition(stop("Hi!"), "x", foo = "bar") | ||
| Condition | ||
| Error in `expect_condition()`: | ||
| ! Failed to compare condition to `pattern`. | ||
| ! Failed to compare condition to `regexp`. | ||
| Caused by error in `grepl()`: | ||
| ! unused argument (foo = "bar") | ||
| Code | ||
| expect_condition(stop("Hi!"), pattern = "bar", fixed = TRUE) | ||
| Condition | ||
| Error in `expect_condition()`: | ||
|
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. looks good 👍 |
||
| ! Can't supply `...` unless `regexp` is set. | ||
| * Unused arguments: `pattern` and `fixed`. | ||
| i Did you mean to use `regexp` so `...` is passed to `grepl()`? | ||
|
|
||
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.
ah, in case it matters, I just came across this admonition to continue avoiding
...names()until 4.1.3 😱r-lib/lintr#2502
https://github.com/r-lib/lintr/blob/dc8f14996fc303d40f120eea6d56fb54187dbc9c/R/lint.R#L43