Skip to content

Conversation

MichaelChirico
Copy link
Collaborator

Part of #962

Can surely be tidied up a bit as part of #963, but filing as is for now to finish of #962.

Comment on lines 70 to 71
"This code relies on stringsAsFactors=TRUE, which will",
"change in the future. Please supply this argument explicitly,",
Copy link
Collaborator

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?

Copy link
Collaborator Author

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())
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@AshesITR AshesITR left a 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!

@AshesITR AshesITR merged commit 36236c3 into master Apr 1, 2022
@AshesITR AshesITR deleted the strings_as_factors branch April 1, 2022 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants