-
Notifications
You must be signed in to change notification settings - Fork 192
New strings_as_factors_linter #1020
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
Conversation
# Conflicts: # man/linters.Rd
# Conflicts: # man/linters.Rd
R/strings_as_factors_linter.R
Outdated
"This code relies on stringsAsFactors=TRUE, which will", | ||
"change in the future. Please supply this argument explicitly,", |
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.
The future as in roughly a year ago 😄
Better say changes in R >= 4.0.0?
Doesn't this lint any data.frame()
call with a literal character argument and without explicit stringsAsFactors
?
In that case the message should be "provide stringsAsFactors or don't use character constants", no?
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.
good point! took another pass at it.
expect_lint("data.frame(x = c('a', 'b'), stringsAsFactors = FALSE)", NULL, strings_as_factors_linter()) | ||
|
||
# strings in argument names to c() don't get linted | ||
expect_lint("data.frame(x = c('a b' = 1L, 'b c' = 2L), stringsAsFactors = FALSE)", NULL, strings_as_factors_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.
Why provide stringsAsFactors
in this test case?
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.
Hmm maybe just sloppy-pasted. But turns out there's a real false positive there!
Probably not picked up on our side because quoted keyword args aren't allowed if not needed, and passing literally-named vectors to data.frame()
seems uncommon. So let's file as a follow-up bug for now.
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.
Rest looks good. Thank you!
Part of #962
Can surely be tidied up a bit as part of #963, but filing as is for now to finish of #962.